php file_exists 檢查文件或目錄是否存在的函數(shù)
更新時間:2010年05月10日 03:04:16 作者:
其實于php教程 file_exists 函數(shù)與 file_exists語法我們早就講過了,下面我們來看看一下關于它的使用方法與實例吧
說明
bool file_exists ( string $filename )
如果由 filename 指定的文件或目錄存在則返回 TRUE,否則返回 FALSE。
其實于php教程 file_exists 函數(shù)與 file_exists語法我們早就講過了,下面我們來看看一下關于它的使用方法與實例吧
路徑的文件或目錄。
在Windows上,使用/ /計算機名/共享/文件名或 計算機名共享文件名,以檢查網(wǎng)絡共享文件。
在 Windows 中要用 //computername/share/filename 或者 \\computername\share\filename 來檢查網(wǎng)絡中的共享文件。
這是一個很簡單的實例一
<?php
$filename = '/jb51.net/aa/to/foo.txt';
if (file_exists($filename)) {
echo "文件$filename exists";
} else {
echo "文件$filename 不存在";
}
?>
輸出結果為:
文件/jb51.net/aa/to/foo.txt己存在
再來看看實例二
<?php
echo file_exists("jb51.net.txt");
?>
這個我們就直接用file_exists來返回ture or false
bool file_exists ( string $filename )
如果由 filename 指定的文件或目錄存在則返回 TRUE,否則返回 FALSE。
其實于php教程 file_exists 函數(shù)與 file_exists語法我們早就講過了,下面我們來看看一下關于它的使用方法與實例吧
路徑的文件或目錄。
在Windows上,使用/ /計算機名/共享/文件名或 計算機名共享文件名,以檢查網(wǎng)絡共享文件。
在 Windows 中要用 //computername/share/filename 或者 \\computername\share\filename 來檢查網(wǎng)絡中的共享文件。
這是一個很簡單的實例一
復制代碼 代碼如下:
<?php
$filename = '/jb51.net/aa/to/foo.txt';
if (file_exists($filename)) {
echo "文件$filename exists";
} else {
echo "文件$filename 不存在";
}
?>
輸出結果為:
文件/jb51.net/aa/to/foo.txt己存在
再來看看實例二
復制代碼 代碼如下:
<?php
echo file_exists("jb51.net.txt");
?>
這個我們就直接用file_exists來返回ture or false
您可能感興趣的文章:
- php通過function_exists檢測函數(shù)是否存在的方法
- php使用function_exists判斷函數(shù)可用的方法
- php !function_exists("T7FC56270E7A70FA81A5935B72EACBE29"))代碼解密
- 解析php函數(shù)method_exists()與is_callable()的區(qū)別
- php判斷類是否存在函數(shù)class_exists用法分析
- php數(shù)組函數(shù)序列之in_array() - 查找數(shù)組中是否存在指定值
- php數(shù)組函數(shù)序列之in_array() 查找數(shù)組值是否存在
- php數(shù)組函數(shù)序列之a(chǎn)rray_key_exists() - 查找數(shù)組鍵名是否存在
- PHP 判斷常量,變量和函數(shù)是否存在
- php判斷某個方法是否存在函數(shù)function_exists (),method_exists()與is_callable()區(qū)別與用法解析
相關文章
php cookis創(chuàng)建實現(xiàn)代碼
php下創(chuàng)建cookis實現(xiàn)代碼2009-03-03