Introduction to the difference between file_exists and Is_file,is_dir in PHP _php tips
Source: Internet
Author: User
It is obvious that file_exists is affected by the ASP, because the ASP not only has FileExists and folderexists,driverexists, then what is the meaning of file_exists in PHP?
PHP file_exists = is_dir + is_file
It can determine whether a file exists, and can determine whether the directory exists. But such a comprehensive function execution is very inefficient, as if the request in ASP does not specify a form or a get,cookies, so the conclusion is:
◦ If you want to determine whether a directory exists, use a standalone function Is_dir (directory)
◦ If you want to determine whether a file exists, use a standalone function is_file (filepath)
Is_file only judge whether the file exists;
File_exists to determine whether the file exists or whether the directory exists;
Is_dir to determine whether the directory exists;
View the manual, although the results of these two functions are cached, but is_file is faster than n times.
There is also a noteworthy:
Files exist in the case, is_file than file_exists faster n times;
If the file does not exist, the is_file is slower than the file_exists;
The conclusion is that the File_exits function does not affect speed because the file really exists, but the is_file effect is large.
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