I am trying to call multiple arguments from a function in php using an array.
Class useful {
function callFunctionFromClass($className, $function, $args = array()) {
return $className::$function($args);
}
}
<?php
require("library/class.php");
$u = new useful;
$u::callFunctionFromClass(new useful, "text", "Test", "Test");
?>
I have the function text() created aswell like so:
function text($msg, $msg2) {
echo $msg;
echo $msg2;
}
I am getting this error message:
Warning: Missing argument 2 for useful::text(),
called in htdocs\class\library\class.php on line 16
and defined in htdocs\class\library\class.php on line 11
Test
Notice: Undefined variable: msg2 in htdocs\class\library\class.php on line 13
This works fine without $msg2 & a second argument. So how is multiple arguments pulled off?
$u::callFunctionFromClass(new useful, "text", "Test", "Test");that should be reporting an error also