1. <?php
  2. if ($handle = opendir('/path/to/directory')) {
  3.     echo "Directory handle: $handlen";
  4.     echo "Entries:n";
  5.     /* This is the correct way to loop over the directory. */
  6.     while (false !== ($entry = readdir($handle))) {
  7.         echo "$entryn";
  8.     }
  9.  
  10.     closedir($handle);}
  11. ?>