3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Base { protected static $property = 'foo'; public function method() { echo self::$property . "\n"; } } class Child extends Base { } echo "base1\n"; $base1 = new Base(); $base1->method(); Base::$property = 'bar'; echo "child\n"; $child = new Child(); $child->method(); echo "base2\n"; $base2 = new Base(); $base2->method();
Output for 7.0.0 - 7.1.0
base1 foo Fatal error: Uncaught Error: Cannot access protected property Base::$property in /in/BFZ2S:15 Stack trace: #0 {main} thrown in /in/BFZ2S on line 15
Process exited with code 255.
Output for hhvm-3.12.0
base1 foo Fatal error: Uncaught Error: Invalid static property access: Base::property in /in/BFZ2S:15 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.0
base1 foo Fatal error: Invalid static property access: Base::property in /in/BFZ2S on line 15
Process exited with code 255.
Output for 5.0.0 - 5.6.28
base1 foo Fatal error: Cannot access protected property Base::$property in /in/BFZ2S on line 15
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/BFZ2S on line 4
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/BFZ2S on line 4
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/BFZ2S on line 4
Process exited with code 255.