file_get_contents

(PHP 4 >= 4.3.0, PHP 5)

file_get_contents -- Reads entire file into a string

Description

string file_get_contents ( string filename [, bool use_include_path [, resource context]])

Identical to file(), except that file_get_contents() returns the file in a string. On failure, file_get_contents() will return FALSE.

file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.

참고: 이 함수는 바이너리 호환(binary-safe)입니다.

작은 정보: fopen wrappers를 설정하면, 이 함수의 파일 이름으로 URL을 사용할 수 있습니다. 파일 이름을 지정하는 방법은 fopen()을 참고하고, 지원하는 URL 프로토콜 목록은 부록 J를 참고하십시오.

참고: Context 지원은 PHP 5.0.0에서 추가되었습니다.

주의

IIS 등의 표준과 호환되지 않는 일부 웹서버에서는 이 방법으로 데이터를 전송할 때 PHP가 경고를 발생합니다. 이러한 웹서버에서 사용할 때는 error_reporting 레벨을 낮춰서, 경고를 포함하지 않도록 하십시오.

See also: fgets(), file(), fread(), include(), and readfile().