The magic methods tend to screw up references in PHP4. I've turned it
off completely myself. My advise is to switch to PHP5 or not use the
overloading.

On Wed, 11 Aug 2004 15:06:51 +0200, Alessandro Vitale
<[EMAIL PROTECTED]> wrote:
> 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
> 
> !DSPAM:411a17dc169931992880537!
> 
> 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to