In PHP, you can use the closedir() function to close the directory. The function of this function is to close the opened directory handle. It accepts an optional parameter to specify the directory path that needs to be closed. If it is omitted, Use the last url link opened by opendir(); the syntax is "closedir (directory path)".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, you can use closedir () function to close the directory.
The closedir() function can close an open directory handle and accepts an optional parameter:
closedir(dir_handle);
Parameter | Description |
---|---|
dir_handle | Optional. Specifies a directory handle resource previously opened by opendir(). If this parameter is not specified, the last link opened by opendir() is used. |
Example: Open a directory using opendir(), read its contents, then close it using closedir()
"; } closedir($dh); } } ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to close directory in php. For more information, please follow other related articles on the PHP Chinese website!