先贴代码
<br /><?php<br /> function table(){<br /> echo "<table align='center' border='1' width='600'>";<br /> echo "<caption><h1>这是表格的标题</h1></caption>";<br /> for($out=0; $out < 10; $out++ ){<br /> $bgcolor = $out%2 == 0 ? "#ffffff" : "green";<br /> $fontcolor = $out%2 == 0 ? "#ffffff" : "#000000";<br /> echo "<tr bgcolor=".$bgcolor.">";<br /> f<em style="color:transparent">本文来源gao.dai.ma.com搞@代*码#网</em><a>搞代gaodaima码</a>or($in=0;$in<10;$in++){<br /> echo "<td>".($out*10+$in)."</td>";<br /> };<br /> echo "</tr>";<br /> };<br /> echo "</table>";<br /> }<br /> table();<br />?><br />
这是一段 PHP 定义函数的代码
tips:
1、注意PHP 的语法格式
2、注意在PHP 中插入Html 代码的方式
3、利用for 循环的时候,注意想清楚,外部循环和里部循环 的差异性