note 75037 added to language.oop5.magic

From: Date: Wed, 09 May 2007 14:47:51 +0000
Subject: note 75037 added to language.oop5.magic
Groups: php.notes 
Request: Send a blank email to php-notes+get-126364@lists.php.net to get a copy of this message
Referering my previus note: there was an error in the code. But i find a better way: <? session_start(); class Classes{ private $name; private $statics; function __construct($name){ $this->name=$name; $this->statics=array(); } function setStatic($k,$v){ if(!is_resource($v)) $this->statics[$k]=$v; } function __wakeup(){ foreach($this->statics as $k=>$v) eval($this->name."::\$".$k."=\$this->statics['".$k."'];"); } } function storeStaticAttributes(){ $classes=get_declared_classes(); foreach($classes as $name){ $reflect=new ReflectionClass($name); if($reflect->isUserDefined()){ $statics=$reflect->getStaticProperties(); if(empty($_SESSION["_classes"])) $_SESSION["_classes"]=array(); if(empty($_SESSION["_classes"][$name])) $_SESSION["_classes"][$name]=new Classes($name); foreach($statics as $k=>$v) $_SESSION["_classes"][$name]->setStatic($k,$v); } } } register_shutdown_function('storeStaticAttributes'); ?> ---- Server IP: 130.206.1.5 Probable Submitter: 80.33.123.53 (proxied: 1.0 SIGASERVER) ---- Manual Page -- http://www.php.net/manual/en/language.oop5.magic.php Edit -- https://master.php.net/note/edit/75037 Del: integrated -- https://master.php.net/note/delete/75037/integrated Del: useless -- https://master.php.net/note/delete/75037/useless Del: bad code -- https://master.php.net/note/delete/75037/bad+code Del: spam -- https://master.php.net/note/delete/75037/spam Del: non-english -- https://master.php.net/note/delete/75037/non-english Del: in docs -- https://master.php.net/note/delete/75037/in+docs Del: other reasons-- https://master.php.net/note/delete/75037 Reject -- https://master.php.net/note/reject/75037 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126364) next »