Easy Tutorial
❮ Func String Strtoupper Func Array Diff Ukey ❯

PHP file_get_contents() Function



Definition and Usage

The file_get_contents() function reads the entire file into a string.

This function is the preferred method for reading the contents of a file into a string. If supported by the server's operating system, it also uses memory mapping techniques to enhance performance.

Syntax

Parameter Description
path Required. Specifies the file to read.
include_path Optional. Set this parameter to '1' if you want to search for the file in the include_path (specified 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. If NULL, it is ignored.
start Optional. Specifies the position in the file to start reading from. This parameter was added in PHP 5.1.
max_length Optional. Specifies the number of bytes to read. This parameter was added in PHP 5.1.

Tips and Notes

Tip: This function is binary-safe. (This means that both binary data, such as images, and character data can be written using this function.)


Example

The above code will output:


❮ Func String Strtoupper Func Array Diff Ukey ❯