note 31748 deleted from language.operators.comparison by didou
| From: | didou@php.net | Date: | Fri, 03 Oct 2003 11:07:01 +0000 |
| Subject: | note 31748 deleted from language.operators.comparison by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57692@lists.php.net to get a copy of this message | ||
Note Submitter: nick@m-tj.co.uk
----
The documented example of the Ternary operator lead me to beleive that it could be interchanged with
an If statement and without having programmed in C the note "operates as in C" didn't
help me. So other people don't fall into the same error herre is what I wa trying to do:
(isset($address1)) ? (echo "value=".$address1) : $address1 = null;
which gave me an "Unexpected 'echo'" error when I was expecting the same result
as if I had used:
if (isset($address1)){
echo "value=".$address1;
} else {
$address1 = null;
}
As I understand it, the Ternary operator is used only for assigning values and can't have
functions as the resultant expressions.