note 10775 added to Logical Operators
| From: | muerte at web-ster dot com | Date: | Sun, 21 Jan 2001 22:41:07 +0000 |
| Subject: | note 10775 added to Logical Operators | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-10052@lists.php.net to get a copy of this message | ||
I was hoping to find an operator similar to ||= functions in perl. My first thought would be:
$i = $i or "default"
But or doesn't work like that. If you want to assign a default value to your variables only if
they're not already assigned you CAN however do:
$i or $i = "default"
The first example does NOT work because the or operator is not overloadable like it is in Perl.
http://www.php.net/manual/en/language.operators.logical.php