3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { var $foo = 1; } $a = new A; $b = $a; // $a and $b are copies of the same identifier // ($a) = ($b) = <id> $b->foo = 2; echo "$a->foo" . $a->foo . PHP_EOL; $c = new A; $d = &$c; // $c and $d are references // ($c,$d) = <id> $d->foo = 2; echo "$c->foo" . $c->foo . PHP_EOL; $e = new A; function foo($obj) { // ($obj) = ($e) = <id> $obj->foo = 2; } foo($e); echo "$e->foo" . $e->foo . PHP_EOL;
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
22 22 22
Output for 5.0.2 - 5.0.5, 5.1.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/hANUc on line 3 22 22 22
Output for 5.0.0 - 5.0.1
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/hANUc on line 3 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 10 22PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 18 22PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 29 22PHP_EOL
Output for 4.3.10 - 4.3.11, 4.4.0 - 4.4.9
11 22 11
Output for 4.3.0 - 4.3.9
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 10 11PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 18 22PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/hANUc on line 29 11PHP_EOL

preferences:
266.73 ms | 402 KiB | 357 Q