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
[EMAIL PROTECTED]
***************************************
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php