Home > Backend Development > PHP Tutorial > php dir function example tutorial_PHP tutorial

php dir function example tutorial_PHP tutorial

WBOY
Release: 2016-07-20 11:00:40
Original
1005 people have browsed it

Reading dir for pseudo-object-oriented mechanisms. The given dir is on. Both properties are available once the dir has been pulled. The handle property can be used with other dir functions such as readdir(), rewinddir() and closedir() ​

dir - an instance of the returned Directory class,

Description
dir
dir(
String$path;
Resource$Handling;
String changed to (invalid)
void rewind(void)
Invalid close (invalid)
)
Reading dir for pseudo-object-oriented mechanisms. The given dir is on. Both properties are available once the dir has been pulled. The handle property can be used with other dir functions such as readdir(), rewinddir() and closedir(). The path attribute is set to the path's dir opening. There are three methods: read, rewind and close.

Example

Example of #dir()

Please note the fashion where the return value of dir::read() is checked in the example below. We explicitly test if the return value is the same (equivalent and of the same type - see comparison operators for more information) to false, because otherwise, any dir item whose name evaluates to false will stop the loop.

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


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445491.htmlTechArticleReading dir of pseudo-object-oriented mechanism. The given dir is on. Both properties are available once the dir has been pulled. The handling property can be used with other dir functions such as readdir(), rewinddir()...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template