3v4l.org

run code in 300+ PHP versions simultaneously
<?php class add{ function add($x,$y) { $total = $x + $y; return $total; } } $obj = new add; $obj->add(1,2); echo $obj;
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Object of class add could not be converted to string in /in/h2ZlD:11 Stack trace: #0 {main} thrown in /in/h2ZlD on line 11
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; add has a deprecated constructor in /in/h2ZlD on line 2 Fatal error: Uncaught ArgumentCountError: Too few arguments to function add::add(), 0 passed in /in/h2ZlD on line 9 and exactly 2 expected in /in/h2ZlD:3 Stack trace: #0 /in/h2ZlD(9): add->add() #1 {main} thrown in /in/h2ZlD on line 3
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26
Fatal error: Uncaught ArgumentCountError: Too few arguments to function add::add(), 0 passed in /in/h2ZlD on line 9 and exactly 2 expected in /in/h2ZlD:3 Stack trace: #0 /in/h2ZlD(9): add->add() #1 {main} thrown in /in/h2ZlD on line 3
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; add has a deprecated constructor in /in/h2ZlD on line 2 Warning: Missing argument 1 for add::add(), called in /in/h2ZlD on line 9 and defined in /in/h2ZlD on line 3 Warning: Missing argument 2 for add::add(), called in /in/h2ZlD on line 9 and defined in /in/h2ZlD on line 3 Notice: Undefined variable: x in /in/h2ZlD on line 5 Notice: Undefined variable: y in /in/h2ZlD on line 5 Catchable fatal error: Object of class add could not be converted to string in /in/h2ZlD on line 11
Process exited with code 255.
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.36, 5.6.0 - 5.6.28
Warning: Missing argument 1 for add::add(), called in /in/h2ZlD on line 9 and defined in /in/h2ZlD on line 3 Warning: Missing argument 2 for add::add(), called in /in/h2ZlD on line 9 and defined in /in/h2ZlD on line 3 Notice: Undefined variable: y in /in/h2ZlD on line 5 Notice: Undefined variable: x in /in/h2ZlD on line 5 Catchable fatal error: Object of class add could not be converted to string in /in/h2ZlD on line 11
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Warning: Missing argument 1 for add::add(), called in /in/h2ZlD on line 9 and defined in /in/h2ZlD on line 3 Warning: Missing argument 2 for add::add(), called in /in/h2ZlD on line 9 and defined in /in/h2ZlD on line 3 Notice: Undefined variable: y in /in/h2ZlD on line 5 Notice: Undefined variable: x in /in/h2ZlD on line 5 Object id #1
Output for 5.0.0 - 5.0.5
Warning: Missing argument 1 for add::add() in /in/h2ZlD on line 3 Warning: Missing argument 2 for add::add() in /in/h2ZlD on line 3 Object id #1
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9
Warning: Missing argument 1 for add() in /in/h2ZlD on line 3 Warning: Missing argument 2 for add() in /in/h2ZlD on line 3 Object

preferences:
218.87 ms | 402 KiB | 363 Q