Php dir function example tutorial

Source: Internet
Author: User
Tags rewind

Read dir of the pseudo object-oriented mechanism. The given dir is open. The two attributes can be opened once the dir has been opened. The processed property can be used with other dir functions, such as readdir (), rewinddir () and closedir ()

Dir-returned instance Directory class,

Description
Dir
Dir (
String $ path;
Resource $ processing;
The string is changed to (invalid)
Invalid rewind (invalid)
Invalid closeness (invalid)
)
Read dir of the pseudo object-oriented mechanism. The given dir is open. The two attributes can be opened once the dir has been opened. The processed property can be used with other dir functions, such as readdir (), rewinddir () and closedir (). The path attribute is set to the dir of the path. There are three methods: Reading, rewind, and closeness.

Instance

Example of # dir ()

Pay attention to fashion. The returned value of dir: Read () is checked in the following example. Whether we explicitly test whether the return value is the same (equivalent to the same type-see more information of comparison operators) false, because otherwise, if the name of any dir item is calculated as false, the loop is stopped.

$ D = dir ("/etc/php5 ");
Echo "Handle:". $ d-> handle. "n ";
Echo "Path:". $ d-> path. "n ";
While (false! ==( $ Entry = $ d-> read ())){
Echo $ entry. "n ";
}
$ D-> close ();
?>


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.