我查看了一个php脚本(whmcs的namesilo模块),发现了这个函数
function namesilo_transactionCall($callType, $call, $params)稍后在脚本中,将使用以下代码调用它
namesilo_transactionCall("getNameServers", $apiServerUrl . "/api/getDomainInfo?version=1&type=xml&key=$apiKey&domain=$sld.$tld");当它被调用时,只有两个参数,并且在声明函数时,$params不是可选的。这怎么可能。我是php的新手。
发布于 2014-01-27 03:48:57
我看到了@Alireza Fallah的评论,并决定回答。为什么这是不可能的?
<?php
function namesilo_transactionCall($callType, $call, $params){
var_dump($callType);
}
namesilo_transactionCall(1,1);
// OUTPUT
1
?>如果没有传递定义的非可选参数解释器生成Warning,如下所示:
Warning: Missing argument 3 for namesilo_transactionCall()设置error_reporting(0) -您永远看不到这一点。通常,您不能像下面这样指定所有参数:
function A(){
print_r(func_get_args());
}
// and call
A(1,2,3,4,5,6,7,8....N);这段代码就可以工作了。查看有关functions的更多信息。
https://stackoverflow.com/questions/21367996
复制相似问题