3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a { $i = 1; public function foo($num) { return ($num + 1); } public function increment() { if($quantity = $this->foo($this->i) > 0) { echo $this->i = ($quantity + 1); } } } $test = new a(); $a->increment(); $a->increment();
Output for 5.4.0 - 5.4.25
Parse error: syntax error, unexpected '$i' (T_VARIABLE), expecting function (T_FUNCTION) in /in/vTO0R on line 4
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /in/vTO0R on line 4
Process exited with code 255.

preferences:
179.35 ms | 1395 KiB | 62 Q