php file_exists 檢查文件或目錄是否存在的函數(shù)
更新時(shí)間:2010年05月10日 03:04:16 作者:
其實(shí)于php教程 file_exists 函數(shù)與 file_exists語(yǔ)法我們?cè)缇椭v過(guò)了,下面我們來(lái)看看一下關(guān)于它的使用方法與實(shí)例吧
說(shuō)明
bool file_exists ( string $filename )
如果由 filename 指定的文件或目錄存在則返回 TRUE,否則返回 FALSE。
其實(shí)于php教程 file_exists 函數(shù)與 file_exists語(yǔ)法我們?cè)缇椭v過(guò)了,下面我們來(lái)看看一下關(guān)于它的使用方法與實(shí)例吧
路徑的文件或目錄。
在Windows上,使用/ /計(jì)算機(jī)名/共享/文件名或 計(jì)算機(jī)名共享文件名,以檢查網(wǎng)絡(luò)共享文件。
在 Windows 中要用 //computername/share/filename 或者 \\computername\share\filename 來(lái)檢查網(wǎng)絡(luò)中的共享文件。
這是一個(gè)很簡(jiǎn)單的實(shí)例一
<?php
$filename = '/jb51.net/aa/to/foo.txt';
if (file_exists($filename)) {
echo "文件$filename exists";
} else {
echo "文件$filename 不存在";
}
?>
輸出結(jié)果為:
文件/jb51.net/aa/to/foo.txt己存在
再來(lái)看看實(shí)例二
<?php
echo file_exists("jb51.net.txt");
?>
這個(gè)我們就直接用file_exists來(lái)返回ture or false
bool file_exists ( string $filename )
如果由 filename 指定的文件或目錄存在則返回 TRUE,否則返回 FALSE。
其實(shí)于php教程 file_exists 函數(shù)與 file_exists語(yǔ)法我們?cè)缇椭v過(guò)了,下面我們來(lái)看看一下關(guān)于它的使用方法與實(shí)例吧
路徑的文件或目錄。
在Windows上,使用/ /計(jì)算機(jī)名/共享/文件名或 計(jì)算機(jī)名共享文件名,以檢查網(wǎng)絡(luò)共享文件。
在 Windows 中要用 //computername/share/filename 或者 \\computername\share\filename 來(lái)檢查網(wǎng)絡(luò)中的共享文件。
這是一個(gè)很簡(jiǎn)單的實(shí)例一
復(fù)制代碼 代碼如下:
<?php
$filename = '/jb51.net/aa/to/foo.txt';
if (file_exists($filename)) {
echo "文件$filename exists";
} else {
echo "文件$filename 不存在";
}
?>
輸出結(jié)果為:
文件/jb51.net/aa/to/foo.txt己存在
再來(lái)看看實(shí)例二
復(fù)制代碼 代碼如下:
<?php
echo file_exists("jb51.net.txt");
?>
這個(gè)我們就直接用file_exists來(lái)返回ture or false
您可能感興趣的文章:
- php通過(guò)function_exists檢測(cè)函數(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判斷某個(gè)方法是否存在函數(shù)function_exists (),method_exists()與is_callable()區(qū)別與用法解析
相關(guān)文章
php cookis創(chuàng)建實(shí)現(xiàn)代碼
php下創(chuàng)建cookis實(shí)現(xiàn)代碼2009-03-03一步一步學(xué)習(xí)PHP(8) php 數(shù)組
與其把PHP中的數(shù)組理解為我們狹義上的“數(shù)組”,我覺(jué)得還不妨把這個(gè)數(shù)組一分為二,一者為我們常規(guī)上的數(shù)組,一者為我們的Dictionary。2010-03-03