Friday, October 28, 2016

How to find how many parameter / Arguments has been passed and there value

code-
<?php
    function parentFunction($name='name') {
        echo "There are total: ".func_num_args()." Arguments passed.<BR>";
        $args = func_get_args();

echo '<pre>';
print_r($args);
echo '</pre>';

//fetch the value
        for($i = 0; $i < count($args); $i++) {
echo "Passed Value: {$args[$i]}<br />";
        }
      }
    parentFunction($name= 'name','email','phone','location');
?>

No comments:

Post a Comment