我正在从Project Euler中休息一下,学习一些 PHP/HTML 来踢球和咯咯笑,我发现了一页简单的练习。所以,在我的“网站”上,我希望有一个有序的链接列表,指向每个练习的页面,但我决定以动态的方式进行,而不是在我做练习时对每个项目进行硬编码。不幸的是,应该包含列表的页面根本不呈现!
假设我的系统上有名为“exawk#.php”的文件,这段代码还有什么问题?对不起,如果它是草率或可怕的,这实际上是我网络编程的第一天。
<html>
<head>
<title> Awaken's Exercises </title>
</head>
<body>
<h1>This page contains "Awaken's Exercises" from
<a href="http://forums.digitalpoint.com/showthread.php?t=642480">
this page</a>.</h1>
<ol>
<?php
$arex = glob("exawk*.php"); // $arex contains
//an array of matching files
$numex = 0;
$i = 0;
foreach( $arex )
{
$numex++;
}
while( $numex >= 0 )
{
echo "<li><a href=" .$arex[$i].
">Problem #" .$numex. ".</a></li>";
$numex--;
$i++;
}
?>
</ol>
</body>
</html>