3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class add{ function add($x,$y) { $total = $x + $y; return $total; } } $obj = new add; $obj->add(1,2); echo $obj;
Output for 7.1.0
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.0.0 - 7.0.14
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 hhvm-3.10.0 - 3.12.0
Warning: add() expects exactly 2 parameters, 0 given in /in/h2ZlD on line 5 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.2.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.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