Send a blank email to [email protected] to get a copy of this message
I ran the following code on 5.0.4 and 5.1.0 with identical results...
Could someone shed light one whether the observed behaviour is
intentional and/or correct?
I expected that one of the following would occur (which obviously doesn't :-):
1. the line commented with 'SET 2' would trigger a
call to __set() (which should fail?).
2. the key "test" would be set in the array returned
by __get() but not it the relevant array stored in
$this->array["insideArray"].
The reason I question whether what si observed below is wanted behaviour is
because I thought the __set() functionality was there to be able
to protect/control what stuffed into an object ... but apparently it's
rather easy to side step.
tia,
Jochem
<?php
class T {
private $array = array();
public function __get( $key ) {
echo "Getting $key\n";
return $this->array[$key];
}
public function __set( $key, $value ) {
echo "Setting $key\n";
$this->array[$key] = $value;
}