In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "PHP file processing directory closing and opening method is what", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "PHP file processing directory closing and opening method is what" it!
Opendir () function, which opens the directory
To open a directory, you need to use the opendir () function.
When it comes to opening a directory, you will think of the operation we mentioned earlier about opening a file, which needs to be opened through the fopen () function. At that time, we mentioned that when you use the fopen () function to open a file, if the target file does not exist, or when there is no target file on the current page, the function will create a file.
When we use the opendir () function to open the target directory, if the target directory does not exist, or if the current page cannot find the target directory, a directory will not be created, and an error will occur in this function.
Now that you know the difference between opening a directory with the opendir () function and opening a file with the fopen () function, let's take a look at the basic syntax format of the opendir () function:
Opendir (string $path [, resource $context])
We need to note that the parameter $path represents the directory path that needs to be opened. If this path is correct, the program will return a pointer to the directory that only wants to be opened. If the directory path is not correct, or the path is correct, but the directory cannot be opened because of an error in the system permissions file system, the function will return an error message or false.
To mask the output of this error message, you can add "@" before the opendir () function.
Next, let's take a look at the application of the opendir () function through an example, as follows:
In the above example, you want to use the opendir () function to open the directory with the path D:\ phpstudy_pro\ WWW.
It should be noted that is_dir () in the above example is used to determine whether the directory under the current path is a directory. The output of the above example is as follows:
Here is how to express another path. An example is as follows:
The directory is in the same directory as the current file
Output result:
Through the above example, we have finished opening the directory, using the opendir () function to open the directory under different path expressions. Let's show you how to close the directory.
Closedir () function, which closes the directory
To close the directory, you need to use the closedir () function.
In the above example, we have opened the directory, and when we have completed the corresponding operation, we want to release the resources used by the operation directory, so it is necessary to close the directory. Let's take a look at the basic syntax format of the closedir () function:
Closedir ([resource $dir_handle])
What we need to note is that the parameter handle is a directory pointer opened using the opendir () function.
Next, let's take a look at the use of the closedir () function through an example, as follows:
Output result:
There is no change in the output, but there is a lot of closedir () closing the directory.
Thank you for your reading, the above is the "PHP file processing directory closing and opening method is what" the content, after the study of this article, I believe you on the PHP file processing directory closing and opening method is what this problem has a deeper understanding, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.