PHP ob_get_length() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The ob_get_length() function is an inbuilt function in PHP that is used to get the length of the current output buffer. The output buffer length is the number of bytes in the buffer. Syntax: ob_get_length(): int|falseParameters: This function does not accept any parameter. Return Values: The ob_get_length() function returns the length of the current output buffer in bytes as an integer. If the output buffering is not active or if there is no content in the buffer then it will return "false". Program 1: The following program demonstrates the ob_get_length() function. PHP <?php // Start output buffering ob_start(); echo "This is content inside the buffer."; $bufferLength = ob_get_length(); echo "Buffer length: " . $bufferLength . " bytes."; ob_end_flush(); ?> Output: This is content inside the buffer. Buffer length: 34 bytesProgram 2: The following program demonstrates the ob_get_length() function. PHP <?php // Start output buffering ob_start(); for ($i = 1; $i <= 10; $i++) { echo "Line " . $i . "<br>"; } // Get the length of the buffer $bufferLength = ob_get_length(); // Display the buffer length echo "Buffer length: " . $bufferLength . " bytes."; // Flush the buffer and // send the contents to the client ob_end_flush(); ?> Output: Line 1Line 2Line 3Line 4Line 5Line 6Line 7Line 8Line 9Line 10Buffer length: 101 bytes.Reference: https://www.php.net/manual/en/function.ob-get-length.php Comment More infoAdvertise with us Next Article PHP ob_get_length() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP - Output Control Similar Reads PHP | Imagick getImageLength() Function The Imagick::getImageLength() function is an inbuilt function in PHP which is used to get the length of an image object in bytes. Syntax: bool Imagick::getImageLength( void) Parameters: This function does not accept any parameter. Return Value: This function returns the image length in bytes. Below 1 min read PHP is_long() Function The is_long() function is an inbuilt function in PHP that is used to check whether the given value is a long integer or not. Syntax: bool is_long(mixed $value) Parameters: This function accepts a single parameter $value that holds the value which needs to check for a long integer. Return Value: This 1 min read PHP ob_get_status() Function The ob_get_status() is an inbuilt function in PHP that is used for retrieving the status of the output buffer. Syntaxob_get_status(bool $full_status = false) : arrayParameter This function accepts only one parameter which is described below. $full_status: This is an optional parameter. If this param 2 min read PHP openssl_cipher_key_length() Function The openssl_cipher_key_length() function is an inbuilt function in PHP that is used to retrieve the key length required for a given cipher algorithm. Syntax: openssl_cipher_key_length(string $cipher_algo): int|false Parameters: This function accepts only one parameter which is described below. $ciph 1 min read PHP | imagefontheight() Function The imagefontheight() function is an inbuilt function in PHP which is used to get the pixel height of a character in the specified font. Syntax: int imagefontheight( int $font ) Parameters:This function accepts a single parameter $font which holds the font value. Its value can be 1, 2, 3, 4, 5 for b 2 min read Like