php目录不存在是怎么判断的-PHP问题

资源魔 38 0

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目次没有存正在是怎样判别的的具体内容,更多请存眷资源魔其它相干文章!

标签: php教程 php故障解决 php使用问题 php目录

抱歉,评论功能暂时关闭!