3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A{ //$x; } function foo($p){ $p->x +=3; } function foo2($p){ $p->x +=1; return $p->x -1; } $a = new A(); $a->x =1; foo($a); $a->x = foo2($a); echo $a-x;
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Creation of dynamic property A::$x is deprecated in /in/c9o7A on line 19 Fatal error: Uncaught Error: Undefined constant "x" in /in/c9o7A:22 Stack trace: #0 {main} thrown in /in/c9o7A on line 22
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Fatal error: Uncaught Error: Undefined constant "x" in /in/c9o7A:22 Stack trace: #0 {main} thrown in /in/c9o7A on line 22
Process exited with code 255.
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /in/c9o7A on line 22 Notice: Object of class A could not be converted to number in /in/c9o7A on line 22 Warning: A non-numeric value encountered in /in/c9o7A on line 22 1
Output for 7.3.32 - 7.3.33, 7.4.26
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /in/c9o7A on line 22 Warning: A non-numeric value encountered in /in/c9o7A on line 22 1
Output for 7.2.0 - 7.2.33
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /in/c9o7A on line 22 Notice: Object of class A could not be converted to int in /in/c9o7A on line 22 Warning: A non-numeric value encountered in /in/c9o7A on line 22 1
Output for 7.1.0 - 7.1.33
Notice: Use of undefined constant x - assumed 'x' in /in/c9o7A on line 22 Notice: Object of class A could not be converted to int in /in/c9o7A on line 22 Warning: A non-numeric value encountered in /in/c9o7A on line 22 1
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.21, 7.0.0 - 7.0.20
Notice: Use of undefined constant x - assumed 'x' in /in/c9o7A on line 22 Notice: Object of class A could not be converted to int in /in/c9o7A on line 22 1

preferences:
199.87 ms | 402 KiB | 213 Q