You are here: Re: [PHP] Like ternary but without the else. « PHP « IT news, forums, messages
Re: [PHP] Like ternary but without the else.

Posted by Justin Lilly on 10/04/96 11:09

This should do the trick:

$something ? $this=$that

-justin


On Fri, 25 Feb 2005 10:36:36 -0800, Chris W. Parker
<cparker@swatgear.com> wrote:
> Hello,
>
> I couldn't find this anywhere on google or PHP's site but I'm pretty
> sure there's an answer to it.
>
> How can I turn the following into something that resembles the ternary
> operator?
>
> <?php
>
> if($something)
> {
> $this = $that;
> }
>
> ?>
>
> I seem to remember it looking something like:
>
> <?php
>
> $this = ($something) || $that;
>
> ?>
>
> Although this isn't syntactically wrong, i.e. no errors, it did not do
> what I hoped it would do. (What it does is assign 1/true.)
>
> Thanks!
> Chris.
>
> p.s. No need to respond if your suggestion is:
>
> <?php
>
> if($something) { $this = $that; }
>
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Justin Lilly
University of South Carolina

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация