<?PHP//define a function with a default value functionMain3 ($f=5,$g=6) { Echo $f*$g; } Main3 (2,3); Echo"<br/>"; //functions with variable parameters (the number of parameters can be changed) functionMain4 () { for($i= 0;$i<Func_num_args();$i++) { $array=Func_get_args();//gets the input parameter, which is an array Echo $array[$i]." <br/> "; }} Main4 (1,2,6);//the number of parameters can be changed//function parameterized (in other languages called proxies or delegates)functionIndex2 () {Echo"BB"; }@$hanshu=index2;//function Variable parameterEcho $hanshu();//parametric variable function//Direct output Echo"<br/>"; STR ($hanshu); functionStr$a) { Echo $a(); }//by method call?>
Notes
Custom functions:
1. Function of the default value:
function Main ($a =5, $b =6)
{
Echo $a * $b;
}
2. Functions of variable parameters:
function Main ()
{
for ($i =0; $i <func_num_args (); $i + +)
{
$array = Func_get_args ();
echo $array [$i]. " <br> ";
}
}
Main (All-in-all)//variable Quantity
3. function parameterization (referred to as proxy or delegate in other languages)
function Index2 ()
{
echo "BB";
}
@ $hanshu = Index2;
$hanshu ();
php--Custom Functions