note 81140 deleted from language.variables by danbrown

From: Date: Sun, 20 Jul 2008 15:58:23 +0000
Subject: note 81140 deleted from language.variables by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142145@lists.php.net to get a copy of this message
Note Submitter: (rot13) yrvsrevx [at] jro [dot] qr ---- @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; }

« previous php.notes (#142145) next »