开发者

Files showing up in terminal run, not in browser

开发者 https://www.devze.com 2023-01-29 00:00 出处:网络
I\'m trying to list the files in a directory, but only the HTML portion of the page shows up in my browser. When I run the page through the PHP ter开发者_高级运维minal interpreter, all the files are l

I'm trying to list the files in a directory, but only the HTML portion of the page shows up in my browser. When I run the page through the PHP ter开发者_高级运维minal interpreter, all the files are listed with the proper HTML tags.

files.php:

<html><head><title>Title</title></head>

<body>

<?php
   $currentdir = '/home/tim/Documents/Web/';
   $dir = opendir($currentdir);
   echo '<ul>';
   while ($file = readdir($dir)){
      echo "<li>$file</li>";
   }
?>

</body>
</html>


If your webserver does parse PHP files, I would suggest putting error_reporting(E_ALL); at the beginning of your script. That will force PHP to spit out any error which may have resulted from path/permission problems, thereby helping you to debug the problem.


PHP should also be available to webserver and .php extension should be associated with php. Depends on the webserver you use, there are different instructions on how to install and enable php.

0

精彩评论

暂无评论...
验证码 换一张
取 消