note 33241 added to language.operators.comparison
| From: | jorgeg at global-tools dot com | Date: | Thu, 19 Jun 2003 22:03:43 +0000 |
| Subject: | note 33241 added to language.operators.comparison | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-50685@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/language.operators.comparison.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33241
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33241&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33241&report=yes