3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A{ public $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.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Undefined constant "x" in /in/MEDPJ:22 Stack trace: #0 {main} thrown in /in/MEDPJ on line 22
Process exited with code 255.
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /in/MEDPJ on line 22 Notice: Object of class A could not be converted to number in /in/MEDPJ on line 22 Warning: A non-numeric value encountered in /in/MEDPJ on line 22 1
Output for 7.3.32 - 7.3.33
Warning: Use of undefined constant x - assumed 'x' (this will throw an Error in a future version of PHP) in /in/MEDPJ on line 22 Warning: A non-numeric value encountered in /in/MEDPJ 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/MEDPJ on line 22 Notice: Object of class A could not be converted to int in /in/MEDPJ on line 22 Warning: A non-numeric value encountered in /in/MEDPJ on line 22 1
Output for 7.1.0 - 7.1.25
Notice: Use of undefined constant x - assumed 'x' in /in/MEDPJ on line 22 Notice: Object of class A could not be converted to int in /in/MEDPJ on line 22 Warning: A non-numeric value encountered in /in/MEDPJ on line 22 1
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33
Notice: Use of undefined constant x - assumed 'x' in /in/MEDPJ on line 22 Notice: Object of class A could not be converted to int in /in/MEDPJ on line 22 1

preferences:
210.94 ms | 402 KiB | 295 Q