In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how php judges that there are several files under the directory, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
Php to determine how many files under the directory: 1, use the scandir () function to get the file and folder names under the directory, will return an array containing file and folder names; 2, use the "count (array)-2" statement to get the number of files under the directory.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, you can use the scandir () and count () functions to determine how many files are in the directory.
Example:
There is an img directory with 8 picture files in it
Implementation code:
Description:
The scandir () function can list the files and folder names in the specified directory. The syntax format of the scandir () function is as follows:
Scandir (string $directory [, int $sorting_order [, resource $context]])
The parameters are described as follows:
$directory: the directory to read
$sorting_order: optional parameter that is used to set the default sorting method
If set to SCANDIR_SORT_DESCENDING or 1, the returned results will be sorted in descending alphabetical order
If set to SCANDIR_SORT_NONE, unarranged results are returned.
Context: an optional parameter that specifies the environment of the directory handle. Context is a set of options that can modify the behavior of the directory stream.
The successful execution of the scandir () function returns an array of file and folder names, or FALSE if execution fails. If the parameter $directory is not a directory, the Boolean value FALSE is returned and an E_WARNING-level error is generated.
The count () function can count the number of all elements in an array, or the number of attributes in an object.
What is the framework of php? php framework: 1. Laravel,Laravel is a free and open source PHP application framework. 2. Phalcon,Phalcon is the fastest PHP framework. 3. Symfony,Symfony is a PHP framework for Web projects. 4. Yii,Yii is a fast, secure and professional PHP framework. CodeIgniter,CodeIgniter is a very agile open source PHP framework. 6. CakePHP,CakePHP is an old PHP framework. 7. Kohana recorder Kohana is an agile but powerful PHP framework.
After reading the above, do you have any further understanding of how php determines how many files are in the directory? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.