Below is a global static variable class, the functions in the class are static functions,
Note the symbol "&" inside, he is used to perform address reference. If you are not familiar with the reference method, please refer to the relevant chapter in the PHP manual.
In addition, this example is implemented in the PHP's PEAR class library, and the static global ERROR in Pear.php is implemented.
Class Statvar {Function & Setinit () {static $ static = '; returnit;} Function Set ($ key, $ value) {$ var = & statvar :: setinit (); $ var [$ key] = $ Value;} Function & Get ($ y) {$ var = & statvar :: setinit (); return $ var [$ key];}} // example: statvar :: set ('aa', 'bb'); echo Statvar :: GET ('aa');?>