note 35552 rejected from control-structures.alternative-syntax by bobby

From: Date: Mon, 25 Sep 2006 15:12:17 +0000
Subject: note 35552 rejected from control-structures.alternative-syntax by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117626@lists.php.net to get a copy of this message
Note Submitter: matheo at step dot polymtl dot ca ---- You can use a short syntax for "if" $a = (condition) ? value if condition is true : value if condition is false; <?php $a = 1 ; $b = 2 ; $is_a_bigger = ($a > $b) ? 1 : 0 ; echo $a_is_bigger ; # returns 0 $a = 2 ; $b = 1 ; $is_a_bigger = ($a > $b) ? 1 : 0 ; echo $is_a_bigger ; # returns 1 ?>

« previous php.notes (#117626) next »