3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bla implements Iterator { private $pos = 0; public function __construct() { $this->pos = 0; } function rewind() { $this->pos = 0; } function current() { return $this->pos; } function key() { return $this->pos; } function next() { $this->pos++; } function valid() { return pos < 3; } } echo "results:"; $bla = new Bla(); $i = 0; function arrara() { foreach($bla as $a) { foreach ($bla as $b) { echo "($a, $b)<br />"; $i++; if ($i > 20) return; } if ($i > 20) return; } } arrara();
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Return type of Bla::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/kHqGX on line 17 Deprecated: Return type of Bla::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/kHqGX on line 27 Deprecated: Return type of Bla::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/kHqGX on line 22 Deprecated: Return type of Bla::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/kHqGX on line 32 Deprecated: Return type of Bla::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/kHqGX on line 12 results: Warning: Undefined variable $bla in /in/kHqGX on line 46 Warning: foreach() argument must be of type array|object, null given in /in/kHqGX on line 46
Output for 8.0.0 - 8.0.30
results: Warning: Undefined variable $bla in /in/kHqGX on line 46 Warning: foreach() argument must be of type array|object, null given in /in/kHqGX on line 46
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
results: Notice: Undefined variable: bla in /in/kHqGX on line 46 Warning: Invalid argument supplied for foreach() in /in/kHqGX on line 46
Output for 5.0.0 - 5.0.5, 7.3.32 - 7.3.33
results: Warning: Invalid argument supplied for foreach() in /in/kHqGX on line 46
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/kHqGX on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting '{' in /in/kHqGX on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/kHqGX on line 3
Process exited with code 255.

preferences:
264.5 ms | 401 KiB | 400 Q