file_get_contents

(PHP 4 >= 4.3.0)

file_get_contents -- Reads entire file into a string

Description

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

Identical to file(), except that file_get_contents() returns the file in a string.

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.

注: 這個函數可安全的使用於二進位。

提示: 如果 fopen wrappers 已啟動,則可藉此函數把檔名當成URL使用。參考 fopen() 有更多關於如何指定檔名的細節和附錄 I支援URL協定的列表。

注: Context support was added with PHP 5.0.0.

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