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

 
(사용자 2명의 중간 판 8개는 보이지 않습니다)
2번째 줄: 2번째 줄:
;PHP unlink()
;PHP unlink()
* 파일을 삭제하는 PHP 함수
* 파일을 삭제하는 PHP 함수
* 성공하면 true, 실패하면 false를 반환함
* 성공하면 true, 실패하면 false를 반환하다.
 
<syntaxhighlight lang='php'>
unlink('path/file.txt');
</syntaxhighlight>
<syntaxhighlight lang='php'>
if( !unlink('path/file.txt') ) {
  echo "failed\n";
}
else {
  echo "success\n";
}
</syntaxhighlight>
 
==예제==
<syntaxhighlight lang='php'>
$fh = fopen('test.text', 'a');
fwrite($fh, 'Hello World');
fclose($fh);
unlink('test.txt');
</syntaxhighlight>


==같이 보기==
==같이 보기==
10번째 줄: 30번째 줄:


==참고==
==참고==
* http://php.net/manual/kr/function.unlink.php
* http://php.net/manual/en/function.unlink.php
* https://www.w3schools.com/php/func_filesystem_unlink.asp
* https://www.w3schools.com/php/func_filesystem_unlink.asp


[[분류: PHP 파일시스템 함수]]
[[분류: PHP 파일시스템 함수]]

2023년 2월 12일 (일) 19:17 기준 최신판

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.txt');

3 같이 보기[ | ]

4 참고[ | ]

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