最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php is_file 判斷給定文件名是否為一個正常的文件

 更新時間:2010年05月10日 02:41:11   作者:  
php is_file 判斷是否為文件的代碼
is_file() 函數(shù)檢查指定的文件名是否是正常的文件。
is_file — Tells whether the filename is a regular file
用法

bool is_file ( string $filename ) $file 為必選參數(shù)
如果文件存在且為正常的文件則返回 TRUE。

來看一個測試is_file經(jīng)典實例
復(fù)制代碼 代碼如下:

<?php
var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>

上例將輸出:
bool(true)
bool(false)
用法二
復(fù)制代碼 代碼如下:

<?php
function isfile($file){
return preg_match('/^[^.^:^?^-][^:^?]*.(?i)' . getexts() . '$/',$file);
//first character cannot be . : ? - subsequent characters can't be a : ?
//then a . character and must end with one of your extentions
//getexts() can be replaced with your extentions pattern
}
function getexts(){
//list acceptable file extensions here
return '(app|avi|doc|docx|exe|ico|mid|midi|mov|mp3|
mpg|mpeg|pdf|psd|qt|ra|ram|rm|rtf|txt|wav|word|xls)';
}
echo isfile('/Users/YourUserName/Sites/index.html');
?>

實例三
復(fù)制代碼 代碼如下:

<?php
function deletefolder($path)
{
if ($handle=opendir($path))
{
while (false!==($file=readdir($handle)))
{
if ($file<>"." AND $file<>"..")
{
if (is_file($path.'/'.$file))
{
@unlink($path.'/'.$file);
}
if (is_dir($path.'/'.$file))
{
deletefolder($path.'/'.$file);
@rmdir($path.'/'.$file);
}
}
}
}
}
?>

此函數(shù)刪除所有事情,定義的文件夾

相關(guān)文章

最新評論

康乐县| 华坪县| 探索| 兴国县| 丹棱县| 肃北| 宣恩县| 赞皇县| 施秉县| 集贤县| 商洛市| 从江县| 天门市| 长海县| 旬邑县| 西安市| 兴化市| 齐河县| 双峰县| 钦州市| 汉川市| 宜阳县| 昂仁县| 巴楚县| 东乌珠穆沁旗| 盐城市| 灵台县| 宾阳县| 将乐县| 绥宁县| 永泰县| 福鼎市| 花莲市| 始兴县| 离岛区| 本溪市| 浦县| 临沂市| 濮阳县| 丽江市| 施秉县|