3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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();
based on kdGgX
Output for 7.0.0 - 7.2.0
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.3.20 - 5.6.28
foo Fatal error: Cannot use object of type C1 as array in /in/KK2Kt on line 16
Process exited with code 255.