3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class x { protected $id = '4'; public function getId(){return $this->id;} } $y = new class extends x { public function setId($q){$this->id = $q;} }; function debug(x $param){ var_dump($param); } debug($y); $y->setId('5'); debug($y);
Output for 7.1.0 - 7.3.0beta1
object(class@anonymous)#1 (1) { ["id":protected]=> string(1) "4" } object(class@anonymous)#1 (1) { ["id":protected]=> string(1) "5" }
Output for hhvm-3.21.3 - 3.22.0
object(class@anonymous$;4)#1 (1) { ["id":protected]=> string(1) "4" } object(class@anonymous$;4)#1 (1) { ["id":protected]=> string(1) "5" }
Output for hhvm-3.18.5
object(class@anonymous$;2)#1 (1) { ["id":protected]=> string(1) "4" } object(class@anonymous$;2)#1 (1) { ["id":protected]=> string(1) "5" }
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/C886U on line 9
Process exited with code 255.