note 81140 added to language.variables
| From: | (rot13) | Date: | Fri, 15 Feb 2008 12:22:07 +0000 |
| Subject: | note 81140 added to language.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136169@lists.php.net to get a copy of this message | ||
@cgorbit: This does not work, because "=" has a lower operator precedence than
"||". The expression "($var = $old || true)" assigns true to $var. I corrected
this and further shortened the function by putting "$old = $var" into the expression, too.
:)
Note the parentheses that are necessary because of the operator precedence of "=" and
"&&".
function var_name(&$var, $scope=0)
{
if (($old = $var) && ($key = array_search($var =
'unique'.rand().'value', !$scope ? $GLOBALS : $scope)) && (($var = $old)
|| true)) return $key;
}
----
Server IP: 69.147.83.197
Probable Submitter: 195.250.48.253
----
Manual Page -- http://www.php.net/manual/en/language.variables.php
Edit -- https://master.php.net/note/edit/81140
Del: integrated -- https://master.php.net/note/delete/81140/integrated
Del: useless -- https://master.php.net/note/delete/81140/useless
Del: bad code -- https://master.php.net/note/delete/81140/bad+code
Del: spam -- https://master.php.net/note/delete/81140/spam
Del: non-english -- https://master.php.net/note/delete/81140/non-english
Del: in docs -- https://master.php.net/note/delete/81140/in+docs
Del: other reasons-- https://master.php.net/note/delete/81140
Reject -- https://master.php.net/note/reject/81140
Search -- https://master.php.net/manage/user-notes.php