【发布时间】:2012-02-16 06:43:06
【问题描述】:
我正在尝试使用已声明的参数类型创建一个函数,以快速检查它们是否采用正确的格式,但是当它返回一个字符串时出现此错误:
Catchable fatal error: Argument 2 passed to myfunction() must be an instance of string, string given, called in path_to_file on line 69 and defined in path_to_file on line 49
例子
function myfunction( array $ARRAY, string $STRING, int $INTEGER ) {
return "Args format correct";
}
myfunction(array("1",'2','3','4'), "test" , 1234);
错在哪里?
【问题讨论】:
-
你不能提示标量值。
-
现在可以了,只需使用 PHP 7.0 php.net/manual/en/…