標籤:
<?phpfunction d_rmdir($dirname) { //刪除非空目錄 if(!is_dir($dirname)) { return false; } $handle = @opendir($dirname); while(($file = @readdir($handle)) !== false){ if($file != ‘.‘ && $file != ‘..‘){ $dir = $dirname . ‘/‘ . $file; is_dir($dir) ? d_rmdir($dir) : unlink($dir); } } closedir($handle); return rmdir($dirname) ;}// if(unlink("F:/111www/1111111111111/test/test2.php")){ //刪除檔案// if(rmdir("F:/111www/1111111111111/test/222")){ //刪除空檔案夾 if(d_rmdir("./111")){ echo "刪除成功"; }else{ echo "刪除失敗"; }?>
chmod("/somedir/somefile", 755); //賦許可權
$arr = explode("/Application",dirname(__FILE__));$ordPath = $arr[0].‘/Public/aj/index.html‘;$newPath = $arr[0].‘/Application/Stage/View/Index/index‘.$id.‘.html‘;$state = copy($ordPath,$newPath); //拷貝檔案$test = file_get_contents($ordPath); //獲得檔案內容$temp = str_replace(‘%keywords%‘,$description, $test); //替換內容$isTrue = file_put_contents($newPath, $temp); //組建檔案
php函數操作檔案