note 84499 deleted from language.oop5.overloading by danbrown

From: Date: Wed, 16 Jul 2008 19:59:28 +0000
Subject: note 84499 deleted from language.oop5.overloading by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-141585@lists.php.net to get a copy of this message
Note Submitter: strafvollzugsbeamter at gmx dot de ---- The following works on my installation (5.2.6 / Windows): <?php class G { private $_p = array(); public function __isset($k) { return isset($this->_p[$k]); } public function __get($k) { $v = NULL; if (array_key_exists($k, $this->_p)) { $v = $this->_p[$k]; } else { $v = $this->{$k} = $this; } return $v; } public function __set($k, $v) { $this->_p[$k] = $v; return $this; } } $s = new G(); $s->A->B->C = 'FOO'; $s->X->Y->Z = array ('BAR'); if (isset($s->A->B->C)) { print($s->A->B->C); } else { print('A->B->C is NOT set'); } if (isset($s->X->Y->Z)) { print_r($s->X->Y->Z); } else { print('X->Y->Z is NOT set'); } // prints: FOOArray ( [0] => BAR ) ?> ... have fun and ...

« previous php.notes (#141585) next »