note 80128 modified in language.variables.variable by danbrown

From: Date: Wed, 24 Jun 2009 16:14:45 +0000
Subject: note 80128 modified in language.variables.variable by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157373@lists.php.net to get a copy of this message
hi, i handling multi-array with like this: i use this for some classes with direct access to $__info array. and i have some config_{set|get} static functions without this class, but handling is the same. i'm not testing this piece of code for benchmark and high load. <?php class __info { private $__info=array(); public function __s($value=null, $id='') { if ($id == '') return false; $id='[\''.$id.'\']'; for ($i=2, $max=func_num_args(), $args=func_get_args(); $i<$max; $i++) $id.='[\''.$args[$i].'\']'; eval(' if (isset($this->__info'.$id.')) { // debug || vyjimka } $this->__info'.$id.'=$value; '); return true; } public function __g($id) { $uid=''; for ($i=0, $max=func_num_args(), $args=func_get_args(); $i<$max; $i++) $uid.="[\'".$args[$i]."\']"; return eval(' if (isset($this->__info'.$uid.')) { return $this->__info'.$uid.'; } else { return false; } // debug || vyjimka '); return false; } ?> --was-- hi, i handling multi-array with like this: i use this for some classes with direct access to $__info array. and i have some config_{set|get} static functions without this class, but handling is the same. i'm not testing this piece of code for benchmark and high load. class __info { private $__info=array(); public function __s($value=null, $id='') { if ($id == '') return false; $id='[\''.$id.'\']'; for ($i=2, $max=func_num_args(), $args=func_get_args(); $i<$max; $i++) $id.='[\''.$args[$i].'\']'; eval(' if (isset($this->__info'.$id.')) { // debug || vyjimka } $this->__info'.$id.'=$value; '); return true; } public function __g($id) { $uid=''; for ($i=0, $max=func_num_args(), $args=func_get_args(); $i<$max; $i++) $uid.="[\'".$args[$i]."\']"; return eval(' if (isset($this->__info'.$uid.')) { return $this->__info'.$uid.'; } else { return false; } // debug || vyjimka '); return false; } http://php.net/manual/en/language.variables.variable.php

« previous php.notes (#157373) next »