一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

兼容PHP5的PHP目錄管理函數(shù)庫

主要能兼容: php 5
一、chdir -- 改變目錄
語法:bool chdir ( string directory )
返回值:整數(shù)
函數(shù)種類: 文件存取
內(nèi)容說明:
將 php 的當前目錄改為directory。directory:新的當前目錄。返回值如果成功則返回 TRUE,失敗則返回 FALSE。
例子講解: 

 程序代碼
<?php
// current directory
echo getcwd() . "/n";
chdir('public_html');
// current directory
echo getcwd() . "/n";
?>


輸出結(jié)果為:
/home/vincent
/home/vincent/public_html

注意:循環(huán)語句中會出現(xiàn)“ Warning: chdir(): No such file or directory (errno 2) in ***** on line *”錯誤。


 程序代碼
<?php
// current directory
echo getcwd() . "/n";
for($i=1; $i<=2; $i++){
chdir('whoist');
// current directory
echo getcwd() . "/n";
}
?>


二、dir -- directory 類
語法:new dir(string directory);
返回值:類
函數(shù)種類: 文件存取
內(nèi)容說明:
這是一個類似面向?qū)ο蟮念悇e類,用來讀取目錄。當目錄參數(shù) directory 打開之后,有二個屬性可用:handle 屬性就像其它非類的函數(shù)所用的 readdir()、rewinddir() 及 closedir();path 屬性則配置打開目錄后的路徑參數(shù)。本類有三個方法 (method):read、rewind 與 close。
class dir {
dir ( string directory )
string path
resource handle
string read ( void )
void rewind ( void )
void close ( void )
}
例子講解: 

 程序代碼
<?php
$d = dir("/etc/php5");
echo "Handle: " . $d->handle . "/n";
echo "Path: " . $d->path . "/n";
while (false !== ($entry = $d->read())) {
echo $entry."/n"; 
}
$d->close();
?>


輸出結(jié)果為:
Handle: Resource id #2
Path: /etc/php5
.
..
apache
cgi
cli

注: read 方法返回的目錄項的順序依賴于系統(tǒng)。
注: 本函數(shù)定義了內(nèi)部類 Directory,意味著不能再用同樣的名字定義用戶自己的類。

三、closedir -- 關(guān)閉目錄句柄
語法:void closedir ( resource dir_handle )
返回值:無
函數(shù)種類: 文件存取
內(nèi)容說明:
關(guān)閉由 dir_handle 指定的目錄流。流必須之前被 opendir() 所打開。
例子講解:

 程序代碼
<?php
$dir = "/etc/php5/";
// Open a known directory, read directory into variable and then close
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        $directory = readdir($dh);
        closedir($dh);
    }
}
?>


四、opendir -- 打開目錄句柄
語法:resource opendir ( string path [, resource context] )
返回值:整數(shù)
函數(shù)種類: 文件存取
內(nèi)容說明:
本函數(shù)用來打開目錄資料流。返回的整數(shù)是可供其它目錄函數(shù)closedir(),readdir() 和 rewinddir() 操作的 handle。如果成功則返回目錄句柄的resource,失敗則返回 FALSE。
例子講解:

 程序代碼
<?php
$dir = "/etc/php5/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
   if ($dh = opendir($dir)) {
       while (($file = readdir($dh)) !== false) {
            echo "filename: $file : filetype: " . filetype($dir . $file) . "/n";
       }
        closedir($dh);
    }
}
?>


輸出結(jié)果為:
filename: . : filetype: dir
filename: .. : filetype: dir
filename: apache : filetype: dir
filename: cgi : filetype: dir
filename: cli : filetype: dir

php技術(shù)兼容PHP5的PHP目錄管理函數(shù)庫,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 一本一本久久a久久综合精品蜜桃 | 婷婷视频网站 | 4s4s4s4s色大众影视 | 婷婷午夜影院 | 精品伊人久久大线蕉地址 | 久久精品九九 | 婷婷激情亚洲 | 国产精品高清在线 | 综合伊人久久 | 91精品免费高清在线 | 美女网站黄色 | 亚洲天堂中文网 | 中文字幕一区二区在线播放 | 91系列在线观看免费 | 91麻豆国产 | 精品午夜久久网成年网 | 国产精品久久网 | 中文字幕国产在线 | 最黄最色视频 | 91精品国产免费久久国语麻豆 | 国内精品视频在线观看 | 国产亚洲精aa在线观看香蕉 | 色老板在线永久免费视频凹凸 | 91精品视频在线免费观看 | 亚洲第一页在线视频 | 日本国产一区二区三区 | 亚洲色图偷| 中文一区二区视频 | 国模青青丰满人体大尺度展示 | 91精品91久久久 | 美女被男人扒开腿猛网站 | 亚洲综合色婷婷 | 久久精品国产亚洲网站 | 深爱五月激情五月 | 成人久久精品 | 成人情趣视频无遮掩免费 | 成人综合婷婷国产精品久久免费 | 亚洲综合情 | 欧美日本一区二区三区 | 激情六月婷婷开心丁香开心 | 97色精品视频在线观看免费 |