note 40898 modified in control-structures.alternative-syntax by bobby

From: Date: Mon, 25 Sep 2006 15:51:28 +0000
Subject: note 40898 modified in control-structures.alternative-syntax by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117633@lists.php.net to get a copy of this message
As a rection on sttoo, if you use nested if's a bit different they are less likely to cause mistakes: [EDITOR'S NOTE: Referenced Note has been removed] <?php $one = true; $two = true; $result = ($one ? "one" : ($two ? "two" : "none")); // $result is "one" $one = false; $result = ($one ? "one" : ($two ? "two" : "none")); // $result is "two" $two = false; $result = ($one ? "one" : ($two ? "two" : "none")); // $result is "none" ?> --was-- As a rection on sttoo, if you use nested if's a bit different they are less likely to cause mistakes: <?php $one = true; $two = true; $result = ($one ? "one" : ($two ? "two" : "none")); // $result is "one" $one = false; $result = ($one ? "one" : ($two ? "two" : "none")); // $result is "two" $two = false; $result = ($one ? "one" : ($two ? "two" : "none")); // $result is "none" ?> http://php.net/manual/en/control-structures.alternative-syntax.php

« previous php.notes (#117633) next »