[PHP4] class overload and ref to objects

From: Date: Wed, 11 Aug 2004 13:06:51 +0000
Subject: [PHP4] class overload and ref to objects
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-193446@lists.php.net to get a copy of this message
Hi all, I have encountered some troubles in trying to achieve the following: - overload class properties by means of __set() and __get() magic functions - store references to objects rather than copies of them in the overloaded class properties using the following code I can actually store and access references to objects, but it doesn't work if I try to call a method on the referenced object: $OO = new overloadedClass(); $OO->new_property = $myObject; // this is a real ref to $myObject echo $OO->new_property->my_property // it works fine $OO->new_property->myFunction(); // doesn't work and produces fatal error the error message looks like this: Fatal error: Class 'overloadedClass' does not support overloaded method calls... any help or suggestion is very much appreciated. thanks, Alessandro ----------------------------- code fragment -------------------- <?php class overloadedClass { var $Properties = array(); function ServicesRepository() { overload("overloadedClass"); } function __set($property_name, &$property_value) { $this->Properties[$property_name] = &$property_value; return true; } function __get($property_name, &$property_value) { if(isset($this->Properties[$property_name])) { $property_value = $this->Properties[$property_name]; return true; } else return false; } } ?> ---------------------------------------------------- *************************************** Alessandro Vitale Jr. Software Engineer Tiscali International Network Spa +39 070 4601678 avitale@tiscali.com ***************************************

« previous php.general (#193446) next »