3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class StaticA { public function setEmail($redirect) { $this->email = $redirect; } function dosomething(){ $obj = new static; $obj->email = $this->email; $obj->classInfo(); } function classInfo(){ echo get_class(new static). "\n"; echo $this->email. "\n"; } } class StaticB extends StaticA { function test(){ //echo get_class(new self). "\n"; parent::classInfo(); } function doit(){ $this->dosomething(); echo $this->email. "\n"; } function dosomething(){ echo "YOU SUCK AT PHOTOSHOP!"; echo parent::dosomething(); echo parent::email; } } $object = new StaticB(); $object->setEmail("erno@01art.de"); $object->doit();
Output for 7.0.0 - 7.1.0
YOU SUCK AT PHOTOSHOP!StaticB erno@01art.de Fatal error: Uncaught Error: Undefined class constant 'email' in /in/USqvv:37 Stack trace: #0 /in/USqvv(30): StaticB->dosomething() #1 /in/USqvv(44): StaticB->doit() #2 {main} thrown in /in/USqvv on line 37
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
YOU SUCK AT PHOTOSHOP!StaticB erno@01art.de Fatal error: Couldn't find constant StaticA::email in /in/USqvv on line 37
Process exited with code 255.
Output for 5.3.0 - 5.6.28
YOU SUCK AT PHOTOSHOP!StaticB erno@01art.de Fatal error: Undefined class constant 'email' in /in/USqvv on line 37
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in /in/USqvv on line 10
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in /in/USqvv on line 10
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/USqvv on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/USqvv on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/USqvv on line 5
Process exited with code 255.