Phpclosedir function-PHP source code

Source: Internet
Author: User
Ec (2); phpclosedir function closedir (in PHP4, in PHP5) closedir-Disable directory handle report error description invalid closedir ([Resource $ dir_handle specified]) Disable directory stream dir_handle specified. The stream must be once opened opendir (). The report error parameter dir_handle specifies that the directory for processing resources is opened with opendir. If the directory handle is not specified, the most "script" ec (2); "script"

Php closedir Function


Closedir
(PHP 4 and PHP 5)

Closedir-close directory handle

Report error description
Invalid closedir ([Resource $ dir_handle specified])
Disable the directory stream dir_handle. The stream must be once opened opendir ().

Report Error Parameters

Dir_handle
The directory for processing resources was previously opened with opendir. If the directory handle is not specified, opendir () opens the assumption in the last step.

View instances

$ Dir = "/etc/php5 /";

// Open a known directory, read directory into variable and then close
If (is_dir ($ dir )){
If ($ dh = opendir ($ dir )){
$ Directory = readdir ($ dh );
Closedir ($ dh );
}
}
?>


Example
// Open the images directory
$ Dir = opendir ("images ");

// List objects in the images directory
While ($ file = readdir ($ dir ))! = False)
{
Echo "filename:". $ file ."
";
}
Closedir ($ dir );
?>

Filename :.
Filename :..
Filename: cat.gif
Filename: dog.gif
Filename: food
Filename: horse.gif

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.