php file_get_contents() function


  Translation results:

UK['kɒntents] US['kɒntents]

n. Content; content; (book, speech, program, etc.) theme; content (plural noun of content); (book, etc.) (of) content, directory; capacity, content; (of books, speeches, programs, etc.) topic

Third person singular: contents Plural: contents Present participle: contenting Past tense: contented Past participle: contented

php file_get_contents() functionsyntax

Function: Read the entire file into a string.

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

Parameters:

ParametersDescription
path Required. Specifies the file to be read.
include_path Optional. If you also want to search for files in include_path, you can set this parameter to "1".
context Optional. Specifies the environment for a file handle. context is a set of options that can modify the behavior of the stream. If null is used, it is ignored.
start Optional. Specifies the position in the file to begin reading. This parameter is new in PHP 5.1.
max_length Optional. Specifies the number of bytes to read. This parameter is new in PHP 5.1.

Description: The preferred method for reading the contents of a file into a string. If supported by the operating system, memory mapping technology is also used to enhance performance.

php file_get_contents() functionexample

<?php
echo file_get_contents("./test.txt");
?>
<?php
echo file_get_contents("http://php.net");
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

复制网站页面,不支持https协议,如需复制https网页,请改用curl

Home

Videos

Q&A