note 109897 deleted from language.variables.superglobals by danbrown
| From: | danbrown@php.net | Date: | Sat, 01 Sep 2012 13:52:04 +0000 |
| Subject: | note 109897 deleted from language.variables.superglobals by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190396@lists.php.net to get a copy of this message | ||
Note Submitter: staff at newsocialife dot com
----
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 :)