The file_get_contents () function reads the entire file into a string.
Like file (), the difference is that file_get_contents () reads the file into a string.
The file_get_contents () function is the preferred method for reading the file content into a string. If supported by the operating system, the memory ing technology will be used to enhance the performance.
Syntax
File_get_contents (path, include_path, context, start, max_length)
*/
Ob_start (); // open the buffer
Echo "hello"; // output content
$ Out1 = ob_get_contents (); // obtain the buffer content
Echo "world"; // output content
$ Out2 = ob_get_contents (); // obtain the buffer content again
Ob_end_clean (); // clear the buffer and disable
Echo $ out1; // output the result obtained for the first time
Echo "<br> ";
Echo $ out2; // output the second result to compare
/*
*/
// This code is used when the output buffer is set to enable (output_buffering = on)
// List the output header information
Print_r (ob_list_handlers ());
// Refresh the buffer data, return the data, and disable the buffer.
$ Buffer = ob_get_flush ();
// Write the buffer data to a file
File_put_contents('buffer.txt ', $ buffer );
// List the output header information
Print_r (ob_list_handlers ());
/*
Obtain the buffer Length
*/
// Open the buffer
Ob_start ();
// Output content
Echo "hello ";
// Obtain the buffer Length
$ Len1 = ob_get_length ();
// Output content again
Echo "world ";
// Obtain the buffer length again
$ Len2 = ob_get_length ();
// Clear the buffer and disable the buffer.
Ob_end_clean ();
// Output the length obtained for the first time
Echo $ len1;
Echo "<br> ";
// Output the length of the second query to compare two different results
Echo $ len2;