Fox example, the next code example will illustrate this:
<?php
function func($name,$type=NULL)
{
echo "$name $type";
}
func("Hello");
echo "<br />";
func("Hello","world");
echo "<br />";
?>
Here $type is an optional argument. It must be set with a default value either NULL or some other value.
Quite simple.Right! In other programming languages, we can achieve similar effects. This is very convenient if we sometimes want to call the same function with different number of arguments.
Also, in PHP API, there are some supplemental functions such as func_num_args(),func_get_arg() and func_num_args() which are to process the arguments passed by the user. This may also help you.