최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday

티스토리 뷰

■ 백엔드 ■/PHP

file_exists

serpiko 2014. 4. 30. 19:00

   file_exists


파일 혹은 디렉토리 존재의 유무를 검사합니다.



   설명


bool file_exists (string $filename)


   인수


filename


파일 혹은 디렉토리의 경로를 적어 줍니다.


참고로 윈도우즈에서는 네트워크 공유가 되어있는 파일을 확인하기 위해  

//computername/share/filename 또는 \\computername\share\filename 로 사용이 가능 합니다.


On windows, use //computername/share/filename or \\computername\share\filename to check files on network shares.


   반환값


지정한 파일이나 디렉토리가 존재하는 경우 TRUE를 반환, 그렇지 않으면 FALSE를 반환 합니다.


Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.


이 기능은 존재하지 않는 파일을 가리키는 심볼릭 링크에 대해 false를 반환하게 됩니다.


    예제


<?php
$filename 
'/path/to/foo.txt';

if (
file_exists($filename)) {
    echo 
"The file $filename exists";
} else {
    echo 
"The file $filename does not exist";
}
?>




댓글