note 110784 deleted from language.operators.logical by danbrown
| From: | danbrown@php.net | Date: | Fri, 07 Dec 2012 18:01:28 +0000 |
| Subject: | note 110784 deleted from language.operators.logical by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192393@lists.php.net to get a copy of this message | ||
Note Submitter: phpnet at zc dot webhop dot net
----
This works similar to javascripts short-curcuit assignments and setting defaults. (e.g. var a =
getParm() || 'a default';)
<?php
($a = $_GET['var']) || ($a = 'a default');
?>
$a gets assigned $_GET['var'] if there's anything in it or it will fallback to
'a default'
Parentheses are required, otherwise you'll end up with $a being a boolean.