note 36189 added to control-structures

From: Date: Tue, 30 Sep 2003 04:25:08 +0000
Subject: note 36189 added to control-structures
Groups: php.notes 
Request: Send a blank email to php-notes+get-57372@lists.php.net to get a copy of this message
You definitely can write a simple control structure like this: <?php if ($var > 5) { $answ = $var1; } else { $answ = $var2; } ?> But there is a much shorter way: <?php $answ = ( $var > 5 ? $var1 : $var2 ); /* $result = ( $expression ? $return_if_true : $return_if_false ) */ ?> ---- Manual Page -- http://www.php.net/manual/en/control-structures.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36189 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36189&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36189&report=yes

« previous php.notes (#57372) next »