3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $myInstance = new MyClass('ciao'); $res = $myInstance->doSomething(); print($res); print("\n"); print($myInstance->getName()); class MyClass { private $_name; public function setName($name) { $this->_name = $name; } public function getName() { return $this->_name; } public function __construct($name) { $this->_name = $name; } public function doSomething($value) { $value = $value . '_MODIFIED'; } }
Output for 7.1.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function MyClass::doSomething(), 0 passed in /in/6gNND on line 5 and exactly 1 expected in /in/6gNND:26 Stack trace: #0 /in/6gNND(5): MyClass->doSomething() #1 {main} thrown in /in/6gNND on line 26
Process exited with code 255.
Output for 5.1.0 - 5.6.28, 7.0.0 - 7.0.14
Warning: Missing argument 1 for MyClass::doSomething(), called in /in/6gNND on line 5 and defined in /in/6gNND on line 26 Notice: Undefined variable: value in /in/6gNND on line 27 ciao
Output for hhvm-3.10.0 - 3.12.0
Warning: doSomething() expects exactly 1 parameter, 0 given in /in/6gNND on line 27 Notice: Undefined variable: value in /in/6gNND on line 27 ciao
Output for 5.0.0 - 5.0.5
Warning: Missing argument 1 for MyClass::doSomething() in /in/6gNND on line 26 ciao
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/6gNND on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/6gNND on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/6gNND on line 12
Process exited with code 255.