Re: if then else short form

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

 



Hello Ben,

Friday, January 21, 2005, 12:01:09 PM, you wrote:

BE> I seem to remember seing someone use a abreaviated form of a
BE> if/them/else of the type that can be used in java.

BE> It was something like

BE> if ( a=b ) ? a=1 ; a=2;

BE> Anybody know what the correct syntax is?

It's called a ternary operator.

$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];

In the PHP manual under Comparison Operators.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I am not young enough to know everything." - Oscar Wilde

-- 
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