Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  php  >  正文 file_exists函数应用实例

file_exists函数应用实例

发布时间:2014-11-18   编辑:www.jquerycn.cn
file_exists函数应用实例

说明:
bool file_exists ( string $filename )

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

在Windows上,使用/ /计算机名/共享/文件名或 计算机名共享文件名,以检查网络共享文件。
在 Windows 中要用 //computername/share/filename 或者 \\computername\share\filename 来检查网络中的共享文件。

实例一
 

复制代码 代码如下:
<?php
$filename = '/jquerycn.cn/aa/to/foo.txt';
if (file_exists($filename)) {
echo "文件$filename exists";
} else {
echo "文件$filename 不存在";
}
?>

输出结果为:
文件/jquerycn.cn/aa/to/foo.txt己存在

实例二
 

复制代码 代码如下:
<?php
echo file_exists("jquerycn.cn.txt");
?>
直接用file_exists来返回ture or false。

您可能感兴趣的文章:
file_exists函数应用实例
php 判断文件存在与否的函数选择(file_exists or is_file)
php文件是否存在 file_exists 用法
检查文件或目录是否存在的函数file_exists()应用举例
PHP file_exists() 函数
PHP is_file与file_exists用法分析
php 创建以unix时间戳命名的文件夹
PHP在线压缩zip的函数代码
php readfile函数下载文件并判断权限的代码示例
php file_exists 检查文件或目录是否存在

[关闭]