Home  >  Article  >  php教程  >  php is_file 判断文件存在

php is_file 判断文件存在

WBOY
WBOYOriginal
2016-06-13 10:03:411124browse

我们利用了file_exists和is_file函数来判断是否为文件和文件是否存在哦,这里我们对路径说了一下特别说明,有需要的朋友可以参考一下。

//用户判断文章是否存 is_file file_exists函数实现

 代码如下 复制代码
 function isFile($path)
 {
  if( file_exists($path) && is_file($path))
 {
  return true;
 }
 else
 {
  return false;
 }
 }

 //注意is_file 与 file_exists函数不能判断绝对路径如我上面的$_path ='/upfile/'就会显示找不到文件,如果用../upfile/就OK了,

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