note 25063 added to control-structures
| From: | simon at rack1 dot php dot net | Date: | Mon, 09 Sep 2002 19:30:16 +0000 |
| Subject: | note 25063 added to control-structures | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36403@lists.php.net to get a copy of this message | ||
For short if-else's:
if ($foo == $bar) {
print "They match";
} else {
print "They don't match";
}
This can quickly be converted into:
($foo == $bar) ? print "They match" : print "They don't match";
This can be useful if the check's intention can be expressed in matter of a single function,
like this.
--
http://www.php.net/manual/en/control-structures.php
http://master.php.net/manage/user-notes.php?action=edit+25063
http://master.php.net/manage/user-notes.php?action=delete+25063
http://master.php.net/manage/user-notes.php?action=reject+25063