"PHP 파일삭제 함수 unlink()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
4번째 줄: 4번째 줄:
* 성공하면 true, 실패하면 false를 반환하다.
* 성공하면 true, 실패하면 false를 반환하다.


<source lang='php'>
<syntaxhighlight lang='php'>
unlink('path/file.txt');
unlink('path/file.txt');
</source>
</syntaxhighlight>
<source lang='php'>
<syntaxhighlight lang='php'>
if( !unlink('path/file.txt') ) {
if( !unlink('path/file.txt') ) {
   echo "failed\n";
   echo "failed\n";
14번째 줄: 14번째 줄:
   echo "success\n";
   echo "success\n";
}
}
</source>
</syntaxhighlight>


==예제==
==예제==
<source lang='php'>
<syntaxhighlight lang='php'>
$fh = fopen('test.text', 'a');
$fh = fopen('test.text', 'a');
fwrite($fh, 'Hello World');
fwrite($fh, 'Hello World');
fclose($fh);
fclose($fh);
unlink('test.html');
unlink('test.html');
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 2일 (월) 02:57 판

1 개요

PHP unlink()
  • 파일을 삭제하는 PHP 함수
  • 성공하면 true, 실패하면 false를 반환하다.
unlink('path/file.txt');
if( !unlink('path/file.txt') ) {
  echo "failed\n";
}
else {
  echo "success\n";
}

2 예제

$fh = fopen('test.text', 'a');
fwrite($fh, 'Hello World');
fclose($fh);
unlink('test.html');

3 같이 보기

4 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}