<?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?>
Shorthand code
<?PHP$s= "n001^ han |n002^ hui |n003^ Manchu |n004^ Uighur"; //break out each row of data $array=Explode("|",$s); $str= "<select>"; for($i= 0;$i<Count($array);$i++) { $hang=$array[$i];//data for each row $lie=Explode("^",$hang);//to remove an array of columns based on Rows $str=$str." <option value= ' ".$lie[0]. "' > ".$lie[1]. " </option> "; } $str=$str." </select> "; Echo $str;?>
Php--explode application (get string, split as drop-down list)