Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 尝试调用未知函数_Php - Fatal编程技术网

Php 尝试调用未知函数

Php 尝试调用未知函数,php,Php,如果函数是可调用的(不仅如果存在,而且如果是可调用的),我必须动态尝试。这是我的代码: try { call_user_func($function, $arguments->arg); } catch (Exception $e) { $condition = $this->_object->getContent("phpCall", "return"); } $function和$arguments->arg是动态变量,例如$function包含md5和$argu

如果函数是可调用的(不仅如果存在,而且如果是可调用的),我必须动态尝试。这是我的代码:

try {
  call_user_func($function, $arguments->arg);
} catch (Exception $e) {
  $condition = $this->_object->getContent("phpCall", "return");
}
$function
$arguments->arg
是动态变量,例如
$function
包含
md5
$arguments->arg
包含
123

我知道PHP中存在函数
md5
,但我得到以下错误:
警告:call\u user\u func()要求参数1是有效的回调,没有在…中给出数组或字符串。

有什么想法吗?

使用

如果要将其传递给call_user_func,请确保$function是字符串。 或者,您可以执行以下操作:

    $function($args);
使用

如果要将其传递给call_user_func,请确保$function是字符串。 或者,您可以执行以下操作:

    $function($args);

听起来call_user_func需要一个包含要调用函数名的字符串。是否改为发送函数指针?

听起来好像call\u user\u func需要一个包含要调用函数名称的字符串。您是否改为发送函数指针