说明 bool file_exists ( string $filename ) 如果由 filename 指定的文件或目录存在则返回 TRUE,否则返回 FALSE。 其实于php教程 file_exists 函数与 file_exists语法我们早就讲过了,下面我们来看看一下关于它的使用方法与实例吧 路径的文件或目录。 在Windows上,使用/ /计算机名/共享/文件名或 计算机名共享文件名,以检查网络共享文件。 在 Windows 中要用 //computername/share/filename 或者 computernamesharefilename 来检查网络中的共享文件。 这是一个很简单的实例一 <div class="codetitle"><a style="CURSOR: pointer" data="46647" class="copybut" id="copybut46647" onclick="doCopy('code46647')"> 代码如下:<div class="codebody" id="code46647"> <?php $filename = '/52php.cn/aa/to/foo.txt'; if (file_exists($filename)) { echo "文件$filename exists"; } else { echo "文件$filename 不存在"; } ?>
输出结果为: 文件/52php.cn/aa/to/foo.txt己存在 再来看看实例二 <div class="codetitle"><a style="CURSOR: pointer" data="38361" class="copybut" id="copybut38361" onclick="doCopy('code38361')"> 代码如下:<div class="codebody" id="code38361"> <?php echo file_exists("52php.cn.txt"); ?>
这个我们就直接用file_exists来返回ture or false (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|