Re: Two very useful PHP functions

From: Date: Fri, 01 May 2009 14:07:40 +0000
Subject: Re: Two very useful PHP functions
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-292181@lists.php.net to get a copy of this message
On Fri, May 1, 2009 at 4:05 AM, Darren <darren@sirdaz.com> wrote: > This was discussed for PHP6, but eventually decided not to have such a > function. Instead, we now have the following:    $var = $_GET['var'] ?: 5; > > Taken from > http://www.corephp.co.uk/archives/19-Prepare-for-PHP-6.html > > 'you'd be able to do something like this: "$foo = $_GET['foo'] ?: > 42;" (i.e. > if foo is true, $foo will equal 42).' > > I don't like that syntax at all. You would have to scrutinize code even more to determine whether a statement like this was intentional or a botched ternary operator. I'm not sure there is a need for a function like ifset/ifsetor, but I'd MUCH rather have a clear function name that could easily be found in the manual than mangling the ternary operator. Andrew

« previous php.general (#292181) next »