<?php
abstract class C {
private $s;
public function __construct($s) {
$this->s = $s;
}
protected function getS() {
return $this->s;
}
}
class C1 extends C {
public function __get($name) {
$value = 'wanted:'.$name;
$this[$name] = $value.',got it again';
return $value;
}
public function __construct($s1) {
parent::__construct($s1);
}
function doStuff() {
echo $this->getS();
echo $this->s;
echo $this->s;
}
}
$c1 = new C1('foo');
$c1->doStuff();
foo
Fatal error: Uncaught Error: Cannot use object of type C1 as array in /in/KK2Kt:16
Stack trace:
#0 /in/KK2Kt(24): C1->__get('s')
#1 /in/KK2Kt(30): C1->doStuff()
#2 {main}
thrown in /in/KK2Kt on line 16
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
foo
Fatal error: Cannot use object of type C1 as array in /in/KK2Kt on line 16
Process exited with code 255.