note 68393 added to language.variables.scope
| From: | wilco dot ict at schippers dot nl | Date: | Tue, 25 Jul 2006 15:05:58 +0000 |
| Subject: | note 68393 added to language.variables.scope | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115158@lists.php.net to get a copy of this message | ||
I was building a class, which would let the user include a file at one point. The included file
needed to be function on a global level though, and not as part of the function. So i came up with
this little trick to work around that.
<?php
// class
private function myInclude() {
// Dirty little trick to turn the scope of this function to a global scope.
foreach ($GLOBALS as $key => $value) {
$$key =& $GLOBALS[$key];
}
include $this->myInclude;
}
?>
----
Server IP: 83.137.20.120
Probable Submitter: 217.166.78.5
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.variables.scope.php
Edit -- http://master.php.net/note/edit/68393
Del: integrated -- http://master.php.net/note/delete/68393/integrated
Del: useless -- http://master.php.net/note/delete/68393/useless
Del: bad code -- http://master.php.net/note/delete/68393/bad+code
Del: spam -- http://master.php.net/note/delete/68393/spam
Del: non-english -- http://master.php.net/note/delete/68393/non-english
Del: in docs -- http://master.php.net/note/delete/68393/in+docs
Del: other reasons-- http://master.php.net/note/delete/68393
Reject -- http://master.php.net/note/reject/68393
Search -- http://master.php.net/manage/user-notes.php