More parameter than expected: no error in PHP?

后端 未结 1 1115
情深已故
情深已故 2021-01-24 17:28

Please see this code, where I pass more parameters than expected to a custom function:

error_reporting(E_ALL);
ini_set(\"display_errors\", 1);

daidai(\"asassa\"         


        
1条回答
  •  抹茶落季
    2021-01-24 17:56

    That is because the setTime() method itself performs a check on the number of parameters, if you want it in your functions, you have to implement it yourself.

    For reference you might look into the docs for func_num_args(), func_get_arg() and func_get_args()

    From the docs:

    No special syntax is required to note that a function is variadic; however access to the function's arguments must use func_num_args(), func_get_arg() and func_get_args().

    Hence, php really treats every function as a variadic one.

    0 讨论(0)
提交回复
热议问题