3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test { public $test = []; public function __construct() { $this->test['foo'] = 'foo'; $this->test['bar'] = 'bar'; } public function getTest(): array { return $this->test; } } $test = new Test; foreach($test->getTest() as $key => $value) { if ($key === 'foo') { $test->test['baz'] = 'baz'; } var_dump($value); }
Output for 7.0.28 - 7.3.0rc3
string(3) "foo" string(3) "bar"
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/Dco0o on line 11
Process exited with code 255.