3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A implements IteratorAggregate { public $b; public funciton __construct(B $b) { $this->b = $b; } public function getIterator() { return $b; } } class B implements IteratorAggregate { public function getIterator() { for ($i = 0; $i < 5; $i++) { yield $i => $i; } } } $a = new A(new B); foreach ($a as $key => $value) { var_dump($key, $value); }
Output for 5.4.0 - 5.4.27
Parse error: syntax error, unexpected 'funciton' (T_STRING), expecting variable (T_VARIABLE) in /in/lfq58 on line 5
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /in/lfq58 on line 5
Process exited with code 255.

preferences:
205.82 ms | 1386 KiB | 64 Q