Opendir syntax: Opendir (Path,context)
Directory, function Description: Open a directory handle, the Opendir () function opens a directory handle, the function returns a directory stream, otherwise returns false. Look at a opendir. Lists all the file instances in the directory, with the following code:
$dirs = './';//Specify the current trap
if (Is_dir ($dirs))
{
$HANLD = Opendir ($dirs);
while (($file = Readdir ($HANLD))!== false)
{
echo "File name:". $file. "<br/>";
}
Closedir ($HANLD);
}
Else
{
Echo ' is not a directory ';
}
/*
Output results
File name: A
File name: b
File name: www.phpfensi.com
*/
Hints and Notes
Note: Starting with PHP 5.0.0, the path parameter supports the ftp://URL wrapper
Note: in PHP 4.3.0, the path parameter can be any URL that supports directory listings, but only the file://URL wrapper in PHP 4 supports this feature.