note 33241 deleted from language.operators.comparison by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 00:17:57 +0000 |
| Subject: | note 33241 deleted from language.operators.comparison by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58442@lists.php.net to get a copy of this message | ||
Note Submitter: jorgeg@global-tools.com
----
To nick at m-tj dot co dot uk
02-May-2003 04:37
There's a page in the manual that explains that you cannot use language constructors in the
ternary operator, but you CAN use functions...echo is a language constructor. Therefore, to
implement the ternary operator you'll either have to:
(isset($address1)) ? (print ("value=".$address1)) : $address1 = null;
changing the language constructor echo for the function print or:
echo (isset($address1) ? ("value=".$address1) : $address1 = null);
I know that in this case if $address1 is not set this line code will try to echo $address1
(coincidentally is null, so it won't echo anything), but for the sake of the example let's
assume it's what we wanted to do.