note 106291 added to language.operators.logical
| From: | brad at bradleyproctor dot com | Date: | Tue, 25 Oct 2011 19:03:59 +0000 |
| Subject: | note 106291 added to language.operators.logical | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184121@lists.php.net to get a copy of this message | ||
A handy way to set a variable using or
<?php
if ($foo) {
$foo = 5;
}
// Can be replaced with
$foo or $foo = 5;
?>
I use this often for setting variables in functions with optional parameters.
<?php
function foobar($a = null, $b = null) {
$a or $a = 10;
$b or $b = 20;
...
}
----
Server IP: 69.147.83.197
Probable Submitter: 66.255.27.100
----
Manual Page -- http://www.php.net/manual/en/language.operators.logical.php
Edit -- https://master.php.net/note/edit/106291
Del: integrated -- https://master.php.net/note/delete/106291/integrated
Del: useless -- https://master.php.net/note/delete/106291/useless
Del: bad code -- https://master.php.net/note/delete/106291/bad+code
Del: spam -- https://master.php.net/note/delete/106291/spam
Del: non-english -- https://master.php.net/note/delete/106291/non-english
Del: in docs -- https://master.php.net/note/delete/106291/in+docs
Del: other reasons-- https://master.php.net/note/delete/106291
Reject -- https://master.php.net/note/reject/106291
Search -- https://master.php.net/manage/user-notes.php