The function reads a file into a string.

Syntax: file_get_contents(path,include_path,context,start,max_length)
Description:

The first parameter “path” is Required. It specifies the file to read.

The second parameter include_path is Optional. It Set this parameter to ‘1’ if you want to search for the file in the include_path (in php.ini) as well.

The third parameter “context” is Optional. It 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.

The fourth parameter “start” is Optional. It Specifies where in the file to start reading. This parameter was added in PHP 5.1.

The fifth parameter “max_length” is Optional. It specifies how many bytes to read. This parameter was added in PHP 5.1.

Example:
Code:

echo file_get_contents("test.txt");

Output:

PHP is an interpreted language.

eXTReMe Tracker