Re: Two very useful PHP functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 1, 2009 at 4:05 AM, Darren <darren@xxxxxxxxxx> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux