Create Function with variable number of argument in PHP

Description

The following code shows how to create Function with variable number of argument.

Example


/*w w  w  . ja v a2s.  c  om*/
<?php
  function makeList()
  {
    print("<ol>\n");
    for($i=0; $i < func_num_args(); $i++)
    {
      print("<li>" . func_get_arg($i) . "</li>\n");
    }
    print("</ol>\n");
  }

  makeList("Linux", "Apache", "MySQL", "PHP");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition