ExamVeda
Login
Home
This question belongs to PHP Functions
Functions
?

Which one of the following PHP functions can be used to build a function that accepts any number of arguments?

Answer & Solution
Correct Answer: Option B
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 */
?>
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.