This is my code.
<?
// image index
// generates an index file containing all images in a particular directory
//point to whatever directory you wish to index.
//index will be written to this directory as imageIndex.html
$dirName = "mm";
$dp = opendir($dirName);
chdir($dirName);
//add all files in directory to $theFiles array
while ($currentFile !== FALSE){
$currentFile = readDir($dp);
$theFiles[] = $currentFile;
} // end while
//extract gif and jpg images
$imageFiles = preg_grep("/jpg$|gif$/", $theFiles);
$output = "";
foreach ($imageFiles as $currentFile){
$output .= <<<HERE
<a href = $dirName/$currentFile>
<img src = "$dirName/$currentFile"
height = 50
width = 50>
</a>
HERE;
} // end foreach
//save the index to the local file system
$fp = fopen("imageIndex.html", "w");
fputs ($fp, $output);
fclose($fp);
//readFile("imageIndex.html");
print "<a href = imageList.php>image index</a>\n";
?>
OUT PUT
Notice: Undefined variable: currentFile in c:\inetpub\wwwroot\thaiseek\imageIndex.php on line 10
image index
The program works fine but

What's wrong on line 10 ?
Why it shows "Notice: Undefined variable" ?
Thank You.