3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { public static $var_1 = 'foo_var'; public static function printItem() { //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 5.3.0 - 5.3.24, 5.4.0 - 5.4.14
Fatal error: Cannot make static method foo::printItem() non static in class bar in /in/vWV2q on line 29
Process exited with code 255.

preferences:
173.65 ms | 1395 KiB | 47 Q