<?php
class A
{
public static function testFunc($name)
{
echo "hello " . $name . ' !!';
}
}
class B
{
public function testAnotherFunc($funcName)
{
echo call_user_func($funcName);
}
}
$b = new B();
$b->testAnotherFunc(array('A', 'testFunc'));
Fatal error: Uncaught ArgumentCountError: Too few arguments to function A::testFunc(), 0 passed in /in/LYOQN on line 18 and exactly 1 expected in /in/LYOQN:6
Stack trace:
#0 /in/LYOQN(18): A::testFunc()
#1 /in/LYOQN(25): B->testAnotherFunc(Array)
#2 {main}
thrown in /in/LYOQN on line 6
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Warning: Missing argument 1 for A::testFunc(), called in /in/LYOQN on line 18 and defined in /in/LYOQN on line 6
Notice: Undefined variable: name in /in/LYOQN on line 8
hello !!
Warning: Missing argument 1 for A::testFunc() in /in/LYOQN on line 6
Notice: Undefined variable: name in /in/LYOQN on line 8
hello !!
Output for 5.0.0 - 5.0.5
Warning: Missing argument 1 for A::testFunc() in /in/LYOQN on line 6
hello !!
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/LYOQN on line 6
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/LYOQN on line 6
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/LYOQN on line 6
Process exited with code 255.