note 34665 added to control-structures.alternative-syntax
| From: | corrupted_wise at yahoo dot com | Date: | Sun, 03 Aug 2003 08:06:41 +0000 |
| Subject: | note 34665 added to control-structures.alternative-syntax | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-53232@lists.php.net to get a copy of this message | ||
Another type of if/else syntax i found, is much like it's perl counterpart. Here's an
example.
This is your normal if/else
if(statement is true) {
$variable = 1;
} else {
$variable = 0;
}
Alternative:
$variable = (statement is true) ? 1 : 0;
Both do the same thing. This took me a while to figure out as no one really talked about it.
----
Manual Page -- http://www.php.net/manual/en/control-structures.alternative-syntax.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34665
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34665&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34665&report=yes