3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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.4.14
Fatal error: Cannot make static method foo::printItem() non static in class bar in /in/q0K2Z on line 29
Process exited with code 255.