File_get_contents The () function reads the entire file into a string, and, like file (), file_get_contents () reads the file into a string.
The file_get_contents () function is the preferred method for reading the contents of a file into a string, and memory-mapping techniques are used to enhance performance if supported by the operating system.
Syntax: file_get_contents (path,include_path,context,start,max_length)
Ob_start (); Open buffer echo "Hello"; Output content $out 1= ob_get_contents (); Get buffer contents echo "World"; Output content $out 2=ob_get_contents (); Get the buffer content again Ob_end_clean (); Clear the buffer and close echo $out 1; Output the results for the first time echo "<br>"; echo $out 2; Outputs the second obtained results to compare
This code is used when output buffering is set to ON (Output_buffering=on)
List Output header information: Print_r (Ob_list_handlers ());
Flush buffer data, return data and close buffer: $buffer =ob_get_flush ();
Write buffer data to file: File_put_contents (' Buffer.txt ', $buffer);
List Output header information: Print_r (Ob_list_handlers ());
To get the buffer length, the instance code is as follows:
Open buffer Ob_start (); The output echo "Hello"; Gets the buffer length $len 1=ob_get_length (); Then output the content echo "World"; Gets the length of the buffer again $len 2=ob_get_length (); Empties the buffer and closes the buffer Ob_end_clean (); Output the length of the first acquisition echo $len 1; echo "<br>"; Outputs the length of the second fetch to compare two different results echo $len 2;