3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Loader { private static $instances; public static function get_instance($class) { if(!isset(self::$instances[$class])) { self::$instances[$class] = new $class(); } return self::$instances[$class]; } public static function debug() { print_r($instances); } } class One{ public function __toString() { return 'One'; } } class Two{ public function __toString() { return 'Two'; } } class Foo{ public function __toString() { return 'Foo'; } } $foo = Loader::instance('Foo'); $one = Loader::instance('One'); $two = Loader::instance('Two'); Loader::debug()
Output for 5.4.0 - 5.4.11
Parse error: syntax error, unexpected end of file in /in/sabun on line 22
Process exited with code 255.
Output for 5.3.0 - 5.3.21
Parse error: syntax error, unexpected $end in /in/sabun on line 22
Process exited with code 255.