1
我怎樣才能知道func_num_args返回函數內部傳遞參數的個數怎麼樣以外的號碼,但PARAM功能具有的實際數量,PHP函數實際PARAMS
我知道???
function foo($x,$y)
{
// any code
}
我怎樣才能動態地知道綁定到功能
我怎樣才能知道func_num_args返回函數內部傳遞參數的個數怎麼樣以外的號碼,但PARAM功能具有的實際數量,PHP函數實際PARAMS
我知道???
function foo($x,$y)
{
// any code
}
我怎樣才能動態地知道綁定到功能
我把它從args來真正NUM SO答案: PHP function to find out the number of parameters passed into function?
func_number_args()僅限於功能這是被稱爲。在運行時,您無法在函數之外動態提取有關函數的信息。
如果你試圖運行時從一個功能的信息,我建議思考的方法:
if(function_exists('foo'))
{
$info = new ReflectionFunction('foo');
$numberOfArgs = $info->getNumberOfParameters(); // this isn't required though
$numberOfRequiredArgs = $info->getNumberOfRequiredParameters(); // required by the function
}
小幅盤整 $信息 - > getParameters(); 是我夢寐以求的 – shereifhawary 2010-07-08 07:36:13