PHP file_get_contents() 함수
❮ PHP 파일 시스템 참조예시
파일을 문자열로 읽습니다.
<?php
echo file_get_contents("test.txt");
?>
정의 및 사용
file_get_contents()는 파일을 문자열로 읽습니다.
이 함수는 파일의 내용을 문자열로 읽는 데 선호되는 방법입니다. 서버에서 지원하는 경우 성능을 향상시키기 위해 메모리 매핑 기술을 사용합니다.
통사론
file_get_contents(path, include_path, context, start,
max_length)
매개변수 값
Parameter | Description |
---|---|
path | Required. Specifies the path to the file to read |
include_path | Optional. Set this parameter to '1' if you want to search for the file in the include_path (in php.ini) as well |
context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream. Can be skipped by using NULL. |
start | Optional. Specifies where in the file to start reading. Negative values count from the end of the file |
max_length | Optional. Specifies the maximum length of data read. Default is read to EOF |
기술적 세부 사항
반환 값: | 문자열의 전체 파일, 실패 시 FALSE |
---|---|
PHP 버전: | 4.3+ |
바이너리 금고: | 예, PHP 4.3에서 |
PHP 변경 로그: | PHP 7.1 - 시작 매개변수 에서 음수 값 지원 PHP 5.1 - 시작 및 max_length 매개변수 추가 |
❮ PHP 파일 시스템 참조