note 103597 deleted from language.operators.comparison by crell

From: Date: Thu, 31 Mar 2022 17:47:39 +0000
Subject: note 103597 deleted from language.operators.comparison by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217882@lists.php.net to get a copy of this message
Note Submitter: zak at minion dot net ---- be careful when trying to concatenate the result of a ternary operator to a string <?php print '<div>'.(FALSE) ? 'TRUE [bad ternary]' : 'FALSE [bad ternary]'; print '<br><br>'; print '<div>'.((FALSE) ? 'TRUE [good ternary]' : 'FALSE [good ternary]'); ?> yields: TRUE [bad ternary] FALSE [good ternary] this is because the ternary evaluates '<div>'.(FALSE) not (FALSE) - so the end result is TRUE

« previous php.notes (#217882) next »