3v4l.org

run code in 500+ PHP versions simultaneously
<?php function foo(&$var) { $var = 2; } $a = 1; foo($a); var_dump($a); class A { public function do() { foo($this); var_dump($this); } public function doo() { $a = new self(); foo($a); var_dump($a); } } $a = new A(); $a->do(); $a->doo();
Output for 7.1.0 - 7.1.32, 7.2.0, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.6
int(2) object(A)#1 (0) { } int(2)
Output for 7.0.0
int(2) int(2) int(2)
Output for 5.3.29
Parse error: syntax error, unexpected T_DO, expecting T_STRING in /in/2PkHO on line 16
Process exited with code 255.
Output for 4.3.0, 4.4.0
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/2PkHO on line 16
Process exited with code 255.

preferences:
67.98 ms | 1029 KiB | 4 Q