Introduction to the difference between file_exists and Is_file,is_dir in PHP
Font: [Increase decrease] Type: Reprint time: 2012-09-12 I want to comment
Obviously file_exists is affected by the ASP, because the ASP not only has fileexists and folderexists,driverexists, so what is the meaning of file_exists in PHP is obviously file_ exists is affected by the ASP, because the ASP not only has FileExists and folderexists,driverexists, then what does PHP file_exists mean?
PHP file_exists = is_dir + is_file
It can determine whether a file exists, or whether the directory exists. But such a comprehensive function execution is very inefficient, just as the request in ASP does not specify a form, or get,cookies, so the conclusion is:
◦ If you want to determine if the directory exists, use the standalone function Is_dir (directory)
◦ If you want to determine if the file exists, use the standalone function is_file (filepath)
Is_file only determine if the file exists;
File_exists determine whether the file exists or whether the directory exists;
Is_dir determine whether the directory exists;
Look at the manual, although the results of both functions are cached, but the is_file is almost n times faster.
There is one more notable:
In the case of file existence, Is_file is faster n times than file_exists;
If the file does not exist, Is_file is slower than 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.
Introduction to the difference between file_exists and Is_file,is_dir in PHP