note 109897 added to language.variables.superglobals
| From: | staff at newsocialife dot com | Date: | Sat, 01 Sep 2012 08:52:40 +0000 |
| Subject: | note 109897 added to language.variables.superglobals | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-190393@lists.php.net to get a copy of this message | ||
You can define your own globals using a simple php class named ¹
( for now works with classes but not with funcitons... )
the really simple class is:
<?php
class ¹ {
function __get($¹) {
return $GLOBALS['¹'.$¹];
}
function __set($¹, $²) {
$this->$¹ = $²;
$GLOBALS['¹'.$¹] = $²;
return $GLOBALS['¹'.$¹];
}
}
?>
and you could use like:
<?php
class main extends ¹ { //is important that main class extends ¹
function test1() {
$this->a = "test";
$this->b = "hello";
}
}
class subclass extends main {
function output() {
echo $this->a."<br />"; //will output test
}
}
$sub = new subclass;
$sub->test1();
$sub->output(); //will output test
echo $¹a; //will output hello
?>
Enjoy :)
----
Server IP: 87.106.1.137
Probable Submitter: 84.138.184.217
----
Manual Page -- http://www.php.net/manual/en/language.variables.superglobals.php
Edit -- https://master.php.net/note/edit/109897
Del: integrated -- https://master.php.net/note/delete/109897/integrated
Del: useless -- https://master.php.net/note/delete/109897/useless
Del: bad code -- https://master.php.net/note/delete/109897/bad+code
Del: spam -- https://master.php.net/note/delete/109897/spam
Del: non-english -- https://master.php.net/note/delete/109897/non-english
Del: in docs -- https://master.php.net/note/delete/109897/in+docs
Del: other reasons-- https://master.php.net/note/delete/109897
Reject -- https://master.php.net/note/reject/109897
Search -- https://master.php.net/manage/user-notes.php