3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class namedClass{ protected $prop; public function __construct($value){ $this->prop = $value; } public function returnProperty($propName){ if( !empty($this->$propName) ){ return $this->$propName; }else{ return 'property not found'; } } } $standardObject = new namedClass('The named class'); echo $standardObject->returnProperty('prop')."\n"; class namedExtension extends namedClass{ private $anotherProp = 'Extended property'; } $extObject = new namedExtension('The named extension'); echo $extObject->returnProperty('anotherProp')."\n"; $anonObj = new class('The anonymous class') extends namedClass{ private $anotherProp = 'Anonymous property'; }; echo $anonObj->returnProperty('anotherProp');
based on tJfQM
Output for 7.0.0 - 7.2.0
The named class property not found property not found
Output for 5.4.1 - 5.6.28
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/FN532 on line 42
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected T_CLASS in /in/FN532 on line 42
Process exited with code 255.