<?php
//无返回值,无参数/*function CreateTable(){ $col=""; //echo $col; $cindex=0; while($cindex<10){ $col.="<td></td>"; $cindex++; } $rindex=0; $row=""; while($rindex<10){ $row.="<tr> $col </tr>"; $rindex++; } echo "<table width='200' height='200' border=1 style='background-color:red;'>$row</table>";}//CreateTable();//无返回值,有参数function CreateTableByNum($colNum,$rowNum){ $col=""; //echo $col; $cindex=0; while($cindex<$colNum){ $col.="<td></td>"; $cindex++; } $rindex=0; $row=""; while($rindex<$rowNum){ $row.="<tr> $col </tr>"; $rindex++; } echo "<table width='200' height='200' border=1 style='background-color:red;'>$row</table>";}CreateTableByNum(4,4);//有返回值,有参数功能:根据传入的参数输出对应的表格
参数:整形,列的数量,行的数量返回值:输出指定行和列的表格字符串function CreateTableByNumAndReturn($colNum,$rowNum){
$col=""; //echo $col; $cindex=0; while($cindex<$colNum){ $col.="<td></td>"; $cindex++; } $rindex=0; $row=""; while($rindex<$rowNum){ $row.="<tr> $col </tr>"; $rindex++; } return "<table width='200' height='200' border=1 style='background-color:red;'>$row</table>";}*///echo CreateTableByNumAndReturn(8,8);/* $a=100; $b=800;function outputVar(){ //global $a;//表示声明使用全局的变量 //echo $a; echo $GLOBALS['a']." ".$GLOBALS['b']."<br/>"; $GLOBALS['a']=400;}outputVar();echo $a."<br/>";function outputVarByref(&$num){//值类型传递过程中是将值进行传递,不会影响原来的值,使用&符号表示将值类型的变量地址传递,所以会影响原来的值 $num=500;}outputVarByref($a);echo $a;function counts(){ static $index=0; echo $index."<br/>"; $index++;}for($i=0;$i<3;$i++){ cOuntS();}counTs();echo function_exists("opendir");*///内部函数
/*function parent(){ echo "这是父函数"; function sub1(){ echo "这是大儿子"; } function sub2(){ echo "这是小儿子"; } }parent();sub1();sub2();