I've just made use of overloaded property access for the first time and
experienced some unexpected behavior.  I just wanted to verify that it was
the correct behavior with those who'd know best.

<?php

class One {
        public function __construct() {
                $this->two = new Two();
        }
        
        public function __set( $n, $v ) {
                $GLOBALS[$n] = $v;
        }
        
        public function __get( $n ) {
                return $GLOBALS[$n];
        }
}

class Two {
        public $property = "default value";     
}

$one = new One();

print( "\"" . $one->two->property . "\"n" );

$one->two->property = "new value";

?>

This produces:
=================
$ php -f test.php
"default value"
PHP Fatal error:  Cannot access undefined property for object with
overloaded property access in /home/fletch/test.php on line 24
=================

Is it correct that $one->two->property should be read only?

Thanks.

Rick Fletcher

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to