note 109896 deleted from language.operators.logical by googleguy
| From: | googleguy@php.net | Date: | Sat, 01 Sep 2012 11:15:46 +0000 |
| Subject: | note 109896 deleted from language.operators.logical by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190394@lists.php.net to get a copy of this message | ||
Note Submitter: jordan at avacweb dot com
----
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.