欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP Directory 函數(shù)的詳解

 更新時間:2013年03月07日 15:18:17   作者:  
PHP Directory 函數(shù)的詳解 ,需要的朋友可以參考一下

預(yù)定義常量:

DIRECTORY_SEPARATOR (string) :目錄分隔符

PATH_SEPARATOR (string) :路徑分隔符


bool chdir ( string $directory )— 改變目錄

復(fù)制代碼 代碼如下:

 echo getcwd() . "\n";
 chdir('public_html');
 echo getcwd() . "\n";


bool chroot ( string $directory )— 改變根目錄,僅在系統(tǒng)支持且運行于 CLI,CGI 或嵌入 SAPI 版本時才行。

dir::dir ( string $directory )— directory 類,有三個方法可用:read,rewind(將文件內(nèi)部的位置指針重新指向一個數(shù)據(jù)流開頭) 和 close

復(fù)制代碼 代碼如下:

$d = dir("E:/work/html");
 foreach($d as $k=>$v){
     echo $k.'->' .$v. '<br/>';
 }
 while(false !== ($entry = $d->read())){
     echo $entry."<br/>";
 }
 $d->close();
 

 void closedir ( resource $dir_handle )— 關(guān)閉目錄句柄

復(fù)制代碼 代碼如下:

$dir = "/etc/php5/";

 if (is_dir($dir)) {
     if ($dh = opendir($dir)){
         $directory = readdir($dh);
         closedir($dh);
     }
 }
 

 string getcwd ( void )— 取得當(dāng)前工作目錄

resource opendir ( string $path [, resource $context ] )— 打開目錄句柄

string readdir ( resource $dir_handle )— 從目錄句柄中讀取條目

復(fù)制代碼 代碼如下:

if ($handle = opendir('/path/to/files')) {
     echo "Directory handle: $handle\n";
     echo "Files:\n";
     while (false !== ($file = readdir($handle))) {
         echo "$file\n";
     }
     closedir($handle);
 }

void rewinddir ( resource $dir_handle ) —將 dir_handle 指定的目錄流重置到目錄的開頭

array scandir ( string $directory [, int $sorting_order [, resource $context ]] )— 列出指定路徑中的文件和目錄

復(fù)制代碼 代碼如下:

 $dir    = '/tmp';
 $files1 = scandir($dir);
 $files2 = scandir($dir, 1);
 print_r($files1);
 print_r($files2);

相關(guān)文章

最新評論