php目录不存在的判断方法:首先创建一个PHP示例文件;然后输入判断语句为“bool file_exists (string $filename)”;最后在浏览器中执行该文件即可判断目录是否存在。
php判断目录是否存在
file_exists — 检查文件或目录存在
说明
bool file_exists ( string $filename )检查文件或目录是否存在。
参数
filename
文件或目录的路径。
在 Windows 中要用 //computername/share/filename 或者 \\computername\share\filename 来检查网络中的共享文件。
返回值
如果由 filename 指定的文件或目录存在则返回 TRUE,否则返回 FALSE。
Note:
This function will return FALSE for symlinks pointing to non-existing files.Warning
如果因为安全模式的限制而导致不能访问文件的话,该函数会返回FALSE。然而,可以使用include 来包含,如果文件在safe_mode_include_dir所指定的目录里。
Note:
The check is done using the real UID/GID instead of the effective one.
Note: 因为 PHP 的整数类型是有符号整型而且很多平台使用32位整型,对2GB以上的文件,一些文件系统函数可能返回无法预期的结果 。
范例
Example #1 测试一个文件是否存在
<?php $filename = '/path/to/foo.txt'; if (file_exists($filename)) { echo "文件 $filename 存在"; } else { echo "文件 $filename 不存在"; } ?> //以上内容来自官方PHP开发帮助文档更多相关知识,请访问PHP中文网!
以上就是php目录不存在是怎么判断的的详细内容!
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did55266
php目录不存在是怎么判断的
阅读:62次