3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public $i = 0; public function method() { return $this->i++; } } $short = [0, 1, 2]; $long = [0, 1, 2]; $foo1 = new Foo(); $foo2 = new Foo(); $long[$foo1->method()] + $long[$foo1->method()] = 1; $short[$foo2->method()] += 1; var_dump($long, $short);
based on 1QgNQ
Output for 5.6.0 - 7.3.1
array(3) { [0]=> int(0) [1]=> int(1) [2]=> int(2) } array(3) { [0]=> int(1) [1]=> int(1) [2]=> int(2) }