<html>
<head>
<title>php first one</title>
<meta http-equiv="Content-Type" content="text/html;charset=gbk" />
</head>
<body>
<?php
function table($o=10, $i=10){
echo "<table border='1' align='center' width='600'>";
echo "<caption><h1>通过函数输出表格</h1></caption>";
for($out=1;$out<=$o; $out++){
$bgcolor=$out%2==0 ? "green" : "gray";
echo "<tr bgcolor=".$bgcolor.">";
for($in=1;$in<=$i;$in++){
echo "<td>" .($out*10+$in)."</td>";
}
echo "</tr>";
}
echo "</table>";
}
table($o=20, $i=20);
?>
</body>
<head>
<title>php first one</title>
<meta http-equiv="Content-Type" content="text/html;charset=gbk" />
</head>
<body>
<?php
function table($o=10, $i=10){
echo "<table border='1' align='center' width='600'>";
echo "<caption><h1>通过函数输出表格</h1></caption>";
for($out=1;$out<=$o; $out++){
$bgcolor=$out%2==0 ? "green" : "gray";
echo "<tr bgcolor=".$bgcolor.">";
for($in=1;$in<=$i;$in++){
echo "<td>" .($out*10+$in)."</td>";
}
echo "</tr>";
}
echo "</table>";
}
table($o=20, $i=20);
?>
</body>
</html>
本文转自 sswqzx 51CTO博客,原文链接:http://blog.51cto.com/sswqzx/1358040