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 Guillermo Rauch on 10/04/57 11:09

On Fri, 25 Feb 2005 18:39:56 -0500, Brian V Bonini <b-bonini@cox.net> wrote:
> On Fri, 2005-02-25 at 13:36, Chris W. Parker wrote:
> > How can I turn the following into something that resembles the ternary
> > operator?
> >
> > <?php
> >
> > if($something)
> > {
> > $this = $that;
> > }
> >
> > ?>
>
> $this = (isset($something)) ? $something : $that;
>
> The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1
> evaluates to TRUE, and expr3 if expr1 evaluates to FALSE.
>
> --
>
> s/:-[(/]/:-)/g
>
> Brian GnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
> ======================================================================
> gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
> Key Info: http://gfx-design.com/keys
> Linux Registered User #339825 at http://counter.li.org
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

What the user actually requested is the following method, fairly used
in bash scripting.

($a == $b) && $a = 'asdasd';

 

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

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