標籤:style blog color os 檔案 資料 div 時間
<?php 讀取檔案夾: $handler = opendir("c:\");//開啟檔案夾 while($dir = readdir($handler)){//遍曆檔案夾 echo $dir; } 讀取檔案夾: $handler = dir("c:/");//開啟檔案夾 while(false !== ($entry = $handler->read())){//遍曆檔案夾 echo $entry; } $handler->close();//關閉控制代碼 判斷是否有讀的許可權 is_readable($file); 判斷檔案是否存在 file_exists($file); 擷取檔案所有內容 file_get_contents($file); 擷取檔案所有內容 $handler = fopem($file,‘r‘);//擷取檔案控制代碼 $data = fread($handler,filesize($file));//擷取檔案所有內容,第二個參數代表取多少位元組 fclose($handler);//銷毀控制代碼 讀取二進位檔案 $data = implode(‘‘,file($file)); 判斷是否有寫的許可權 is_writable($file); 寫檔案內容 file_put_content($file); 寫檔案內容 $handler = fopen($file,‘w‘);//擷取檔案控制代碼 fwrite($handler,$data);//寫資料 fclose($handler); 鎖 $handler = fopen($file,‘w‘); flock($handler,LOCK_EX);//為檔案申請拍它型鎖 fwrite($handler,$data);//寫資料 flock($handler,LOCK_UN);//釋放鎖 fclose($handler); 刪除檔案 unlink($file); 複製檔案 copy($file,$newfile);參數1為被複製的檔案,參數2為複製到的檔案 重新命名檔案夾 rename(); 時間 擷取檔案最後一次修改時間 filemtime 擷取檔案最後一次訪問時間 fileatime 擷取檔案所有者 fileowner 擷取檔案位元組大小 filesize($file); 擷取檔案的全部資訊 stat($file);?>