php中file_exists函数使用详解
说明:
boolfile_exists(string$filename)
如果由filename指定的文件或目录存在则返回TRUE,否则返回FALSE。
在Windows上,使用//计算机名/共享/文件名或计算机名共享文件名,以检查网络共享文件。
在Windows中要用//computername/share/filename或者\\computername\share\filename来检查网络中的共享文件。
实例一
<?php $filename='/jb51.net/aa/to/foo.txt'; if(file_exists($filename)){ echo"文件$filenameexists"; }else{ echo"文件$filename不存在"; } ?>
输出结果为:
文件/jb51.net/aa/to/foo.txt己存在
实例二
<?php echofile_exists("jb51.net.txt"); ?>
直接用file_exists来返回tureorfalse。
以上所述就是本文的全部内容了,希望大家能够喜欢。