<?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';
}
}
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.
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 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.
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.