PHP檔案夾操作2

來源:互聯網
上載者:User

標籤:color   world   檔案夾   code   write   lin   fclose   資源   檔案   

mkdir("路徑檔案名稱");    建立檔案夾imdir("路徑檔案名稱");    刪除檔案夾(只能刪除空的檔案夾)rename("路徑","新路徑");    移動檔案夾(可以修改名字)檔案操作:touch("路徑");    建立檔案copy("檔案路徑","新檔案路徑");    複製檔案unlink("檔案路徑");        刪除檔案file_get_contents("檔案路徑");    擷取檔案內容(本地內容、遠程內容都可以擷取)file_put_contents("檔案路徑"."內容");    寫入內容raedfile("檔案名稱");        讀取問件內容並輸出
$f = fopen("./11.txt","r");     //開啟檔案並返迴文件資源fwrite($f,"hello world");     //寫入內容echo fgetc($f);     //讀取檔案內容,一個字元一個字元的讀echo fgets($f);     //讀取檔案內容,每次讀一行echo fread($f,10);     //讀取檔案內容,按照長度來讀fclose($f);     //關閉檔案資源

刪除檔案

function ShanChu($fname){    //遍曆該檔案夾,找到所有檔案刪除    $dir = opendir($fname);    while($n = readdir($dir))    {        if($n!="." && $n!="..")        {            $zname = $fname."/".$n;            if(is_file($zname))            {                unlink($zname);            }            else            {                ShanChu($zname);            }        }    }    closedir($dir);    //刪除檔案夾    rmdir($fname);}ShanChu("./0904");

 

PHP檔案夾操作2

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.