php的多功能檔案操作類

2022-06-10 15:33:10 字數 1800 閱讀 4140

本類為檔案操作類,實現了檔案的建立,寫入,刪除,修改,複製,移動,建立目錄,刪除目錄,列出目錄裡的檔案等功能,路徑後面別忘了加"/"

建立指定路徑下的指定檔案

* @param string $path(需要包含檔名和字尾)

* @param boolean $over_write 是否覆蓋檔案

* @param int $time 設定時間。預設是當前系統時間

* @param int $atime 設定訪問時間。預設是當前系統時間

<?php/**

*本類為檔案操作類,實現了檔案的建立,寫入,刪除,修改,複製,移動,建立目錄,刪除目錄

* 列出目錄裡的檔案等功能,路徑後面別忘了加"/" */

class

fileoperate

else

else

}}/*

* * 本方法用來寫檔案,向path路徑下name檔案寫入content內容,bool為寫入選項,值為1時

* 接著檔案原內容下繼續寫入,值為2時寫入後的檔案只有本次content內容

** @param string_type path

* @param string_type name

* @param string_type content

* @param bool_type bool

*/function write_file($path,$name,$content,$bool) //

寫檔案

$result=fwrite($handle,$content

);

if (!$result

)

echo "檔案寫入成功";

fclose($handle

); }

else

echo "檔案不存在";

} if ($bool==2)

else

}}/*

* * 本方法刪除path路徑下name檔案

** @param string_type path

* @param string_type name

*/function del_file($path,$name)

else

else

echo "檔案刪除失敗";

}} /**

* 本方法用來修改path目錄裡name檔案中的內容(可視)

** @param string_type path

* @param string_type name

*/function modi_file($path,$name)

/** * 本方法用來複製name檔案從spath到dpath

** @param string name

* @param string spath

* @param string dpath

*/function copy_file($name,$spath,$dpath) //

檔案複製

else

echo "檔案不存在";}

/*** 本方法把name檔案從spath移動到path路徑

** @param string_type path

* @param string_type dirname

* @param string_type dpath

*/function move_file($name,$spath,$dpath) //

移動檔案

else}}

?>

php檔案操作類

本類為檔案操作類,實現了檔案的建立,寫入,刪除,修改,複製,移動,建立目錄,刪除目錄 列出目錄裡的檔案等功能,路徑後面別忘了加 class fileoperate else else 本方法用來寫檔案,向path路徑下name檔案寫入content內容,bool為寫入選項,值為1時 接著檔案原內容下...

設計乙個多功能的MyTime類

題目內容 定義乙個帶過載建構函式的日期類date,資料成員有年 月 日 成員函式包括 乙個帶引數的建構函式date int,int,int 乙個不帶引數的建構函式 設定日期為1900年1月1日 乙個按 年 月 日 格式顯示日期的函式,乙個對資料成員賦值的函式void init int,int,int...

功能強大的php檔案上傳類

檔案上傳類 class upfile 如果資料夾不存在則建立資料夾 function creatfolder f path 判斷檔案是不是超過上傳限制 function is big 檢查檔案型別 function check type 檢查檔案是否存在 function check file na...