note 15384 deleted from function.eval by jimw

From: Date: Sat, 08 Dec 2001 23:25:55 +0000
Subject: note 15384 deleted from function.eval by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22329@lists.php.net to get a copy of this message
The similar way as shown in the above example you can access any object initialized at php script. For example if you want to use list of currently initialized objects in a class just do it this way: //somewhere in php code $o = new object_or_class; $o->id = 153; //now define class that works with objects defined in scripts using this class class Objects { function global_object ($object_name) { eval ("global \$$object_name;"); $newo = ${$object_name}; return $newo; } //and now access all object methods and variables like this: function foo { $object_name = "name of existing object" $ox = $this->global_object($object_name); echo $ox->id; } //this way it doesn't work function foo2 { echo $o->id; } } $d = new Objects; $d->foo; //will print 153 $d->foo2; //will print empty string happy codding

« previous php.notes (#22329) next »