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

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

 更新時(shí)間: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。

來看一個(gè)測(cè)試is_file經(jīng)典實(shí)例
復(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');
?>

實(shí)例三
復(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)文章

最新評(píng)論

邻水| 商南县| 太仓市| 荣成市| 东辽县| 武安市| 淳安县| 广宗县| 红河县| 五大连池市| 竹山县| 石嘴山市| 札达县| 通河县| 乐东| 青川县| 元谋县| 威信县| 吉安县| 清水县| 东城区| 保德县| 万荣县| 泾川县| 西贡区| 景宁| 故城县| 江都市| 大洼县| 格尔木市| 宁陕县| 日土县| 潜山县| 修文县| 兴宁市| 阜南县| 宜宾县| 广灵县| 砀山县| 榆中县| 屯门区|