php is_file 判断文件存在

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

  1. function isFile($path)
  2. {
  3. if( file_exists($path) && is_file($path))
  4. {
  5. return true;
  6. }
  7. else
  8. {
  9. return false;
  10. }
  11. }

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