Which of the following PHP functions accepts any number of parameters?

Đăng Khánh

New member
Which of the following PHP functions accepts any number of parameters?
A. func_get_argv()
B. func_get_args()
C. get_argv()
D. get_argc()
 
Answer: b
Explanation: func_get_args() returns an array of arguments provided. One can use func_get_args() inside the function to parse any number of passed parameters. Here is an example:
Code:
function foo()
{
    $args = func_get_args();
    foreach ($args as $k => $v)
    {  
       echo "arg".($k+1).": $v\n";  
    }
}
foo();
/* will print nothing */
foo("Hello");
/* will print Hello */
foo("Hello","World","Bye");
/* will print Hello World Bye */
 

Tìm kiếm

Back
Top