note 76245 added to language.variables
| From: | alexandre at nospam dot gaigalas dot net | Date: | Sat, 07 Jul 2007 04:13:36 +0000 |
| Subject: | note 76245 added to language.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128278@lists.php.net to get a copy of this message | ||
Here's a simple solution for retrieving the variable name, based on the lucas
(http://www.php.net/manual/en/language.variables.php#49997) solution, but shorter, just two lines =)
<?php
function var_name(&$var, $scope=0)
{
$old = $var;
if (($key = array_search($var = 'unique'.rand().'value', !$scope ? $GLOBALS
: $scope)) && $var = $old) return $key;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 189.29.194.38
----
Manual Page -- http://www.php.net/manual/en/language.variables.php
Edit -- https://master.php.net/note/edit/76245
Del: integrated -- https://master.php.net/note/delete/76245/integrated
Del: useless -- https://master.php.net/note/delete/76245/useless
Del: bad code -- https://master.php.net/note/delete/76245/bad+code
Del: spam -- https://master.php.net/note/delete/76245/spam
Del: non-english -- https://master.php.net/note/delete/76245/non-english
Del: in docs -- https://master.php.net/note/delete/76245/in+docs
Del: other reasons-- https://master.php.net/note/delete/76245
Reject -- https://master.php.net/note/reject/76245
Search -- https://master.php.net/manage/user-notes.php