[ Web 관련 ]/php
php 파일 존재 체크
BIZLAB
2023. 2. 24. 13:00
file_exists() 와 is_file() 그리고 file() 함수 사용
file_exists('/폴더/file.txt'); 처럼 안될 경우
file_exists('./폴더/file.txt'); 처럼 해볼 것
https://webisfree.com/2015-02-03/[php]-서버에-특정-파일이-있는지-확인-file-exists()-is-file()-file()
다른 서버의 파일 확인 경우
file_get_contents() 활용
- 전체파일을 문자열로 읽어들이는 PHP 함수
- 로컬파일, 원격파일 모두 가능
$str = file_get_contents('test.txt');
echo $str;
# John Smith
$str = file_get_contents('http://zetawiki.com/ex/txt/utf8hello.txt');
echo $str;