php中file_exists函数使用详解

  说明:

  bool file_exists ( string $filename )

  如果由 filename 指定的文件或目录存在则返回 TRUE,否则返回 FALSE。

  在Windows上,使用/ /计算机名/共享/文件名或 计算机名共享文件名,以检查网络共享文件。

  在 Windows 中要用 //computername/share/filename 或者 \\computername\share\filename 来检查网络中的共享文件。

  实例一

<?php
$filename = '/glzy8.com/aa/to/foo.txt';
if (file_exists($filename)) {
echo "文件$filename exists";
} else {
echo "文件$filename 不存在";
}
?>

  输出结果为:

  文件/glzy8.com/aa/to/foo.txt己存在

  实例二

<?php
echo file_exists("glzy8.com.txt");
?>

  直接用file_exists来返回ture or false。

  以上所述就是本文的全部内容了,希望大家能够喜欢。