好惨,最近又感冒了
函数是一个被命名的,独立的代码段,它执行特定功能,并可以给调用它的程序返回一个值。
函数的声明
function 函数名(){
函数体
}
<?php
table();
table();
function table(){
echo '<table border=1 width="800" align="center">';
echo '<caption><h1>表名</h1></caption>';
for($i=0; $i<10; $i++){
if($i%2==0)
$bg="#ffffff";
else
$bg="#cccccc";
echo '<tr bgColor="'.$bg.'">';
for($j=0; $j<10;$j++ ){
echo '<td>'.($i*10+$j).'</td>';
}
echo '</tr>';
}
echo '</table>';
}
?>