Re: if then else short form
| From: | Richard Davey | Date: | Fri, 21 Jan 2005 12:10:17 +0000 |
| Subject: | Re: if then else short form | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-206923@lists.php.net to get a copy of this message | ||
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