【发布时间】:2020-07-27 09:27:32
【问题描述】:
我有以下代码来显示 php 文件夹中的文件。
<html>
<head>
<?php require '/opt/bitnami/apps/wordpress/htdocs/head.php';?>
</head>
<body>
<br>
<br>
<br>
<br>
<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".."&& $file != "posts.php") {
$thelist .= '<a href="'.$file.'">'.$file.'</a><hr>';
}
}
closedir($handle);
}
?>
<center>
<h1>files</h1>
<br>
<br>
<div style=background-color:white;color:black;>
<br>
<p1 style="font-size: 25px;"><?php echo $thelist;?></p1><br>
<hr>
</div>
</center>
</body>
</html>
所以,我不希望 .php 文件扩展名在列出时不显示。例如,如果有一个名为 test.php 的文件,我希望它只列出 test.php。我应该添加/更改什么代码才能使其正常工作?
感谢您的帮助。
【问题讨论】:
-
我认为这是xyproblem.info