一、在PHP中将九九乘法口诀表分别用table和div来显示出来
1.用table来显现:
<?php
function Create_Multiplication_formulas_in_Table() {
$cellss = array ();
for($i = 0; $i < 9; $i ++) {
$cellss [$i] = array ();
}
for($i = 1; $i <= 9; $i ++) {
for($j = 1; $j <= $i; $j ++) {
$cellss [$i - 1] [$j - 1] = "$i*$j=" . $i * $j . " ";
}
}
return $cellss;
}
$cells = Create_Multiplication_formulas_in_Table ();
function ShowTable($cellss) {
echo "<table cellpadding=10 border=1 > ";
foreach ( $cellss as $cell ) {
echo "<tr >";
foreach ( $cell as $value ) {
echo "<td align=left>";
echo " $value";
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
}
ShowTable ( $cells );
?>
2.用div来显现:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>乘法口诀表</title>
</head>
<style>
.box
{
width:3000px;
height:300px;
}
.faceul
{
height:17px;
display:block;
}
.faceul li
{
list-style-type:none;
}
.faceul li span
{
float:left;
margin-left:10px;
display:block;
}
</style>
<body>
<?php
function CreateMultiplicationformulasinTable() {
$cellss = array ();
for($i = 0; $i < 9; $i ++) {
$cellss [$i] = array ();
}
for($i = 1; $i <= 9; $i ++) {
for($j = 1; $j <= $i; $j ++) {
$cellss [$i - 1] [$j - 1] = "$i*$j=" . $i * $j . " ";
}
}
return $cellss;
}
$cells = CreateMultiplicationformulasinTable ();
function showDiv($cellss)
{
echo "<div class='box'>";
foreach ($cellss as $cell)
{
echo "<ul class='faceul'>";
foreach ($cell as $value)
{
echo "<li>";
echo "<span>";
echo " $value";
echo "</span>";
echo "</li>";
}
echo "</ul>";
}
}
showDiv($cells);
?>
</body>
</html>
两种不同的显示效果如下;
*注:1.对于php来说一般一个函数只实现一个功能;
2.对于zend studio 来说ctrl+shift+F可以实现自动排版功能
二、对于写一个页面可以使用960.gs来进行css布局
这是960.gs网站,在上面可以下载
对于如何使用960gs下面有一篇文章对此做了详细的的解释,我在次就不废话了。
作为一个初学者,我发现如果写一个页面没有用例如960gs来布局,自己硬写就会非常的麻烦代码一多就会出现混乱。