3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('error_reporting', -1); ini_set('display_errors', 'on'); class Foo { private static $a; public function __construct() { self::$a = range('A', 'Z'); } public function generator() { while(self::$a) { yield array_reverse(array_pop(self::$a)); } } } $foo = new Foo; $generator = $foo->generator(); if ($generator->valid()) { foreach($generator as $i) { echo $i; } } else { echo 'Nothing'; } $generator = $foo->generator(); if ($generator->valid()) { foreach($generator as $i) { echo $i; } } else { echo 'Nothing'; }
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: array_reverse(): Argument #1 ($array) must be of type array, string given in /in/TZku6:19 Stack trace: #0 /in/TZku6(19): array_reverse('Z') #1 [internal function]: Foo->generator() #2 /in/TZku6(26): Generator->valid() #3 {main} thrown in /in/TZku6 on line 19
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.12 ms | 401 KiB | 8 Q