3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function uppercase(Traversable $in) { foreach ($in as $word) { yield strtoupper($word); } } function reverse(Traversable $in) { foreach ($in as $word) { yield strrev($word); } } function each_println(Traversable $in) { foreach ($in as $line) { echo "$line\n"; } } each_println(strrev(uppercase(new ArrayIterator(["foo", "bar", "baz"]))));
Output for 7.0.0 - 7.1.0
Warning: strrev() expects parameter 1 to be string, object given in /in/KB6hI on line 24 Fatal error: Uncaught TypeError: Argument 1 passed to each_println() must implement interface Traversable, null given, called in /in/KB6hI on line 24 and defined in /in/KB6hI:17 Stack trace: #0 /in/KB6hI(24): each_println(NULL) #1 {main} thrown in /in/KB6hI on line 17
Process exited with code 255.
Output for hhvm-3.12.0
Warning: strrev() expects parameter 1 to be string, object given in /in/KB6hI on line 24 Fatal error: Uncaught TypeError: Argument 1 passed to each_println() must implement interface Traversable, null given in /in/KB6hI:22 Stack trace: #0 /in/KB6hI(24): each_println() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Warning: strrev() expects parameter 1 to be string, object given in /in/KB6hI on line 24 Catchable fatal error: Argument 1 passed to each_println() must implement interface Traversable, null given in /in/KB6hI on line 22
Process exited with code 255.
Output for 5.5.0 - 5.6.28
Warning: strrev() expects parameter 1 to be string, object given in /in/KB6hI on line 24 Catchable fatal error: Argument 1 passed to each_println() must implement interface Traversable, null given, called in /in/KB6hI on line 24 and defined in /in/KB6hI on line 17
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected 'strtoupper' (T_STRING) in /in/KB6hI on line 6
Process exited with code 255.
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/KB6hI on line 6
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/KB6hI on line 6
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/KB6hI on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting ')' in /in/KB6hI on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/KB6hI on line 3
Process exited with code 255.