note 70751 added to language.variables.scope
| From: | squeegee at osu1 dot php dot net | Date: | Thu, 26 Oct 2006 14:36:11 +0000 |
| Subject: | note 70751 added to language.variables.scope | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119136@lists.php.net to get a copy of this message | ||
here's an interesting use of global
function whatever($prefix){
$a = "${prefix}var1";
$b = "${prefix}var2";
$c = "${prefix}var3";
$d = "${prefix}var4";
global $$a, $$b, $$c, $$d;
This lets you reference different sets of variables that are named with a common suffix, but the
prefix can change.
i.e. 1st time you call it, let's say you want to use variables named
$myvar1, $myvar2, $myvar3, $myvar4
and the next time you call it, you want to use variables named
$yourvar1, $yourvar2, $yourvar3, $yourvar4
----
Server IP: 216.194.113.175
Probable Submitter: 66.188.26.156
----
Manual Page -- http://www.php.net/manual/en/language.variables.scope.php
Edit -- https://master.php.net/note/edit/70751
Del: integrated -- https://master.php.net/note/delete/70751/integrated
Del: useless -- https://master.php.net/note/delete/70751/useless
Del: bad code -- https://master.php.net/note/delete/70751/bad+code
Del: spam -- https://master.php.net/note/delete/70751/spam
Del: non-english -- https://master.php.net/note/delete/70751/non-english
Del: in docs -- https://master.php.net/note/delete/70751/in+docs
Del: other reasons-- https://master.php.net/note/delete/70751
Reject -- https://master.php.net/note/reject/70751
Search -- https://master.php.net/manage/user-notes.php