3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function gen_one_to_three() { for ($i = 1; $i <= 3; $i++) { // Note that $i is preserved between yields. yield $i; } } $generator = gen_one_to_three(); var_dump($generator); die; abstract class T { static public $instanses; final private function __construct(){ } public static function getInstance() { if (!(static::$instanses instanceof static)) { static::$instanses = new static; } return static::$instanses; } } class A extends T { static public $instanses; } class B extends A { static public $instanses; } $t = A::getInstance(); var_dump($t); $t1 = B::getInstance(); var_dump($t1); new B(); ?>
based on Dcfsu
Output for 5.5.24 - 7.2.0
object(Generator)#1 (0) { }
Output for 5.4.9 - 5.4.45
Parse error: syntax error, unexpected '$i' (T_VARIABLE) in /in/YaXCC on line 5
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/YaXCC on line 5
Process exited with code 255.