Which one of the following PHP functions can be used to build a function that accepts any number of arguments?
A. func_get_argv()
B. func_get_argc()
C. get_argv()
D. get_argc()
Answer: Option B
Solution(By Examveda Team)
Here is an example-<?php
function foo()
{
$args = func_get_args();
foreach ($args as $k => $v)
{
echo "arg".($k+1).": $vn";
}
}
foo();
/* will print nothing */
foo("Hello");
/* will print Hello */
foo("Hello","World","Bye");
/* will print Hello World Bye */
?>
Related Questions on Functions
Which one of the following is the right way of defining a function in PHP?
A. function { function body }
B. data type functionName(parameters) { function body }
C. functionName(parameters) { function body }
D. function fumctionName(parameters) { function body }
A. Call By Value
B. Call By Reference
C. Default Argument Value
D. Type Hinting
Join The Discussion