php 路径 函数不存在,php目录不存在是怎么判断的
php目錄不存在的判斷方法:首先創(chuàng)建一個PHP示例文件;然后輸入判斷語句為“bool file_exists (string $filename)”;最后在瀏覽器中執(zhí)行該文件即可判斷目錄是否存在。
php判斷目錄是否存在
file_exists — 檢查文件或目錄存在
說明bool file_exists ( string $filename )
檢查文件或目錄是否存在。
參數(shù)
filename
文件或目錄的路徑。
在 Windows 中要用 //computername/share/filename 或者 \\computername\share\filename 來檢查網(wǎng)絡中的共享文件。
返回值
如果由 filename 指定的文件或目錄存在則返回 TRUE,否則返回 FALSE。
Note:This function will return FALSE for symlinks pointing to non-existing files.
Warning
如果因為安全模式的限制而導致不能訪問文件的話,該函數(shù)會返回 FALSE。然而,可以使用 include 來包含,如果文件在 safe_mode_include_dir 所指定的目錄里。
Note:
The check is done using the real UID/GID instead of the effective one.
Note: 因為 PHP 的整數(shù)類型是有符號整型而且很多平臺使用32位整型, 對2GB以上的文件,一些文件系統(tǒng)函數(shù)可能返回無法預期的結(jié)果 。
范例
Example #1 測試一個文件是否存在
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
echo "文件 $filename 存在";
} else {
echo "文件 $filename 不存在";
}
?>
//以上內(nèi)容來自官方PHP開發(fā)幫助文檔
更多相關知識,請訪問PHP中文網(wǎng)!
總結(jié)
以上是生活随笔為你收集整理的php 路径 函数不存在,php目录不存在是怎么判断的的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: webpack+vue-cli 中pro
- 下一篇: apache php并发数,apache