<?php 
// Note that !== did not exist until 4.0.0-RC2 
if ($handle = opendir('file:///E:/')) { 
    echo "Directory handle: $handle\n"; 
    echo "Files:\n"; 
			echo "<br>";

    /* This is the correct way to loop over the directory. */ 
    while (false !== ($file = readdir($handle))) { 
        echo "$file\n"; 
				echo "<br>";
    } 

    /* This is the WRONG way to loop over the directory. */ 
    while ($file = readdir($handle)) { 
        echo "$file\n"; 
		echo "<br>";
    } 

    closedir($handle); 
} 
?> 

List all files in the current directory:
<?php 
if ($handle = opendir('.')) { 
    while (false !== ($file = readdir($handle))) { 
        if ($file != "." && $file != "..") { 
            echo "$file\n"; 
					echo "<br>";
        } 
    } 
    closedir($handle); 
} 
?>