Home >Backend Development >PHP Tutorial >php is_file determines the existence of a file_PHP tutorial
We used the file_exists and is_file functions to determine whether it is a file and whether the file exists. Here we have some special instructions for the path. Friends in need can refer to it.
//User determines whether the article exists is_file file_exists function implementation
代码如下 | 复制代码 |
function isFile($path) { if( file_exists($path) && is_file($path)) { return true; } else { return false; } } |
//Note that the is_file and file_exists functions cannot determine the absolute path. For example, my $_path ='/upfile/' above will show that the file cannot be found. If you use ../upfile/, it will be OK.