note 103202 deleted from control-structures.if by googleguy

From: Date: Tue, 15 Jan 2013 04:39:56 +0000
Subject: note 103202 deleted from control-structures.if by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193042@lists.php.net to get a copy of this message
Note Submitter: lallemand dot mathieu at gmail dot com ---- Be careful when you chain inline "if" : <?php $x = 1; $y = 3; echo ($x==1) ? "One" : ($y == 2) ? "Two" : "None"; ?> Expected result : "One". Result on screen : "Two". Pretty disapointing isn't it ? So, if you want to chain inline "if" you have to use parentesis on each test like below: <?php $x=1; $y=3; echo ($x==1) ? "One" : ( ($y==2) ? "Two" : "None" ); ?> Result on screen : "One". Hope it helps !

« previous php.notes (#193042) next »