Files showing up in terminal run, not in browser

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 terminal 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>

Answers


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.


Need Your Help

How to retrieve value from clicked star on rating system

javascript php jquery ajax json

I am working a project in PHP is dont really know much of ajax, javascript or json but i know i can do this if pointed to the right direction.

Is there any differences between these jQuery selectors?

jquery jquery-selectors

What is the difference between the three samples below and which one is better (if any)?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.