我刚开始使用PHP,并尝试设计一个简单的代码,在其中定义一些随机生成的多维整数数组并将它们显示到网页上。
但是,当我尝试访问Apache.php
提供的服务时,Web 浏览器不显示该网页。我的代码中缺少什么?
<html>
<head>
<title>
Novatos del PHP
</title>
</head>
<body>
<?php
$m1 = array ( array (rand(0,100), rand(0,100), rand(0,100)),
array (rand(0,100), rand(0,100), rand(0,100)),
array (rand(0,100), rand(0,100), rand(0,100)),
array (rand(0,100), rand(0,100), rand(0,100))
);
$m2 = array ( array (rand(0,100), rand(0,100), rand(0,100)),
array (rand(0,100), rand(0,100), rand(0,100)),
array (rand(0,100), rand(0,100), rand(0,100)),
array (rand(0,100), rand(0,100), rand(0,100))
);
printMatrix($m1);
function printMatrix($matrix){
echo "<table width=\"200\" border=\"1\">";
foreach($matrix as $row =$rValue){
echo "<tr>";
foreach($rValue as $col =$cValue){
echo "<td>".$cValue."</td>";
}
echo "</tr>";
}
echo "</table>";
}
?>
</body>
</html>