3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { public static $var_1 = 'foo_var'; public static function printStaticItem() { //echo 'Foo: ' . self::$var_1 . PHP_EOL; } public function printPHP() { echo 'PHP is great.' . PHP_EOL; } } class bar extends foo { public static $var_1 = 'static_bar_var'; public $var_2 = 'bar_var'; public static function printStaticItem() { echo 'Bar: ' . static::$var_1 . PHP_EOL; echo "Bar: {static::$static_var_1}" . PHP_EOL; } public function printItem() { echo "Bar: {$this->$var_2}" . PHP_EOL; } } bar::printStaticItem(); bar::printItem();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Bar: static_bar_var Warning: Undefined variable $static_var_1 in /in/RponS on line 24 Bar: {static::} Fatal error: Uncaught Error: Non-static method bar::printItem() cannot be called statically in /in/RponS:34 Stack trace: #0 {main} thrown in /in/RponS on line 34
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.33
Bar: static_bar_var Notice: Undefined variable: static_var_1 in /in/RponS on line 24 Bar: {static::} Deprecated: Non-static method bar::printItem() should not be called statically in /in/RponS on line 34 Fatal error: Uncaught Error: Using $this when not in object context in /in/RponS:27 Stack trace: #0 /in/RponS(34): bar::printItem() #1 {main} thrown in /in/RponS on line 27
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Bar: static_bar_var Bar: {static::} Fatal error: Uncaught Error: Using $this when not in object context in /in/RponS:27 Stack trace: #0 /in/RponS(34): bar::printItem() #1 {main} thrown in /in/RponS on line 27
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Bar: static_bar_var Notice: Undefined variable: static_var_1 in /in/RponS on line 24 Bar: {static::} Strict Standards: Non-static method bar::printItem() should not be called statically in /in/RponS on line 34 Fatal error: Using $this when not in object context in /in/RponS on line 27
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_STATIC in /in/RponS on line 22
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STATIC in /in/RponS on line 22
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/RponS on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/RponS 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/RponS on line 5
Process exited with code 255.

preferences:
266.94 ms | 401 KiB | 356 Q