note 39153 added to control-structures
| From: | MageOfChrisz at Diabloworld dot com | Date: | Mon, 19 Jan 2004 03:33:41 +0000 |
| Subject: | note 39153 added to control-structures | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-63810@lists.php.net to get a copy of this message | ||
As the person said below, you for assigning variables, you can use:
<?PHP
$foo = 1;
$bar = 2;
$foobar = ($foo == 1) ? $foo + $bar : $bar;
?>
Which is saying
VARIABLE = (IF STATEMENT) ? If the statement is true: if it's false;
You can even have and / or / xor in it
<?PHP
$foo = 1;
$bar = 2;
$foobar = ( ($foo == 1) && ($bar == 2) ) ? 3 : 1;
?>
----
Manual Page -- http://www.php.net/manual/en/control-structures.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39153
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39153&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39153&report=yes
Search -- http://master.php.net/manage/user-notes.php