파일 작업 함수
1445 단어 파일 작업
/**
*
+-------------------------------------------------
* @param string $file
* @return string
+-------------------------------------------------
*/
function read($file) {
$hd = fopen($file, "r");
$cont = fread($hd, filesize($file));
fclose($hd);
return $cont;
}
/**
*
+-------------------------------------------------
* @param string $file
* @param string $cont
+-------------------------------------------------
*/
function write($file, $cont='', $mode='w') {
$hd = fopen($file, $mode);
fwrite($hd, $cont);
fclose($hd);
}
//
function _mkdir($dir, $mode=0777) {
if (is_dir($dir) || @mkdir($dir, $mode)) return true;
if (!_mkdir(dirname($dir), $mode)) return false;
return @mkdir($dir, $mode);
}
//
function _rmdir ($dir, $self=true) {
if (!is_dir($dir)) return false;
$handle = opendir($dir);
while (($file = readdir($handle)) !== false) {
if ($file != "." && $file != "..") {
is_dir("$dir/$file") ? _rmdir("$dir/$file") : unlink("$dir/$file");
}
}
if ($self && readdir($handle) == false) {
closedir($handle);
rmdir($dir);
}
return true;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
PHP 파일 작업 기반 상세 설명형식: fopen(filename,mode) 설명: 지정한 형식으로 지정한 파일 열기: 열 파일 이름 모드: 열 모드 fopen("hello.txt", w").쓰는 방식으로 hello를 열 수 있음을 나타냅니다.tx...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.