php - Create a variable parameter list -
im looking bit of advice, have visited this page in manual, might wrong page or misinterpreted instructions still confused.
i have following question assignment above. know:
- 1st , foremost variable-length parameter?
- creating function not problem however, how set number of argumnets, since according question (if understand correctly) function should able take number of arguments. guess comes 1st question regarding variable-length paramenters again...?
thank reading
to use variable length parameters on php need function func_get_args()
instead define parameters on function declaration. function this:
function foo() { $params_count = func_num_args(); $params_values = func_get_args(); }
on $params_values
there parameters given foo()
function. on params_count
there number of parameters given foo()
. can number of parameters given foo function func_num_args()
an example of using functions (https://3v4l.org/twd3v):
function foo() { $params_count = func_num_args(); var_dump($params_count); $params_values = func_get_args(); var_dump($params_values); }
Comments
Post a Comment