php代码示例以下:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <h3>国际象棋棋盘</h3> <table width="270px" cellspacing="0px" cellpadding="0px" border="1px"> <!-- cell 270px wide (8 columns x 60px) --> <?php for($row=1;$row<=8;$row++) { echo "<tr>"; for($col=1;$col<=8;$col++) { $total=$row+$col; if($total%2==0) { echo "<td height=30px width=30px bgcolor=#FFFFFF></td>"; } else { echo "<td height=30px width=30px bgcolor=#000000></td>"; } } echo "</tr>"; } ?> </table> </body> </html>
这里我们运用PHP嵌套for轮回来建立一个棋盘,表格宽度="270px",并将30px作为单元格的高度和宽度。
输出结果以下:
本篇文章就是关于用PHP完成国际象棋棋盘的款式结果要领引见,简朴风趣,愿望对须要的朋侪有所协助!
以上就是PHP完成国际象棋棋盘的款式结果(代码示例)的细致内容,更多请关注ki4网别的相干文章!