Home > Article > Backend Development > Examples of ob_get_length buffering and obtaining buffer length in php, phpob_get_length_PHP tutorial
The example in this article describes the method of ob_get_length buffering and obtaining the buffer length in php. Share it with everyone for your reference. The specific method is as follows:
The file_get_contents() function reads the entire file into a string. It is the same as 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 contents of a file into a string. If the operating system supports it, memory mapping technology will also be used to enhance performance.
Syntax: file_get_contents(path,include_path,context,start,max_length)
This code is used when output buffering is set to on (output_buffering=on)
List output header information: print_r(ob_list_handlers());
Refresh the buffer data, return the data and close the 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());
Get the buffer length, the example code is as follows:
I hope this article will be helpful to everyone’s PHP programming design.