note 109896 added to language.operators.logical
| From: | jordan at avacweb dot com | Date: | Sat, 01 Sep 2012 00:01:56 +0000 |
| Subject: | note 109896 added to language.operators.logical | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-190392@lists.php.net to get a copy of this message | ||
You can use the OR operator in a similar way to Javascript to return the last evaluated value.
For instance, in Javascript is common to do: var x = foo || bar;
Assigning x to bar when foo evaluates to false.
In PHP you can do this in a similar manner like:
<?php
$foo or ($x = $bar);
?>
Doing the same thing. Assigning $x to $bar, when $foo evaluates to false.
----
Server IP: 69.147.83.197
Probable Submitter: 82.38.181.70
----
Manual Page -- http://www.php.net/manual/en/language.operators.logical.php
Edit -- https://master.php.net/note/edit/109896
Del: integrated -- https://master.php.net/note/delete/109896/integrated
Del: useless -- https://master.php.net/note/delete/109896/useless
Del: bad code -- https://master.php.net/note/delete/109896/bad+code
Del: spam -- https://master.php.net/note/delete/109896/spam
Del: non-english -- https://master.php.net/note/delete/109896/non-english
Del: in docs -- https://master.php.net/note/delete/109896/in+docs
Del: other reasons-- https://master.php.net/note/delete/109896
Reject -- https://master.php.net/note/reject/109896
Search -- https://master.php.net/manage/user-notes.php