Home  >  Article  >  Backend Development  >  The difference between is_file and file_exists in php

The difference between is_file and file_exists in php

WBOY
WBOYOriginal
2016-07-25 08:52:041267browse
Let’s introduce the difference between is_file and file_exists in PHP. is_file only determines whether the file exists; file_exists determines whether the file exists or whether the directory exists;

Share the difference between is_file and file_exists in php for your reference.

is_file only determines whether the file exists; file_exists determines whether the file exists or whether the directory exists; is_dir determines whether the directory exists;

Looking at the php manual, although the results of these two functions will be cached, is_file is N times faster.

Notes: When the file exists, is_file is N times faster than file_exists; When the file does not exist, is_file is slower than file_exists;

Conclusion: The file_exits function will not affect the speed depending on whether the file actually exists, but the impact of is_file will be greater.



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn