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 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 PHP | ip2long() Function The ip2long() function is an inbuilt function in PHP that converts IPv4 address (dotted IP address) into a long integer. Syntax:Â int ip2long( string $ip_address ) Parameters: This function accepts single parameter as mentioned above and described below:Â Â $ip_address: It is required parameter which 2 min read PHP | getimagesize() Function The getimagesize() function in PHP is an inbuilt function which is used to get the size of an image. This function accepts the filename as a parameter and determines the image size and returns the dimensions with the file type and height/width of image. Syntax: array getimagesize( $filename, $image_ 2 min read PHP | Gmagick getimagewidth() Function The Gmagick::getimagewidth() function is an inbuilt function in PHP which is used to get the image width which is the horizontal length of the image. Syntax: int Gmagick::getimagewidth( void ) Parameters:This function doesnât accept any parameter. Return Value: This function returns an integer value 1 min read PHP | Imagick getImageWidth() Function The Imagick::getImageWidth() function is an inbuilt function in PHP which is used to get the width of the image. Syntax: int Imagick::getImageWidth( void ) Parameters: This function does not accepts any parameters. Return Value: This function returns the image width in pixels. Original Image Below p 1 min read PHP | Imagick getSize() Function The Imagick::getSize() function is an inbuilt function in PHP which is used to get the size associated with the imagick object. Syntax: array Imagick::getSize( void ) Parameters: This function doesnât accepts any parameter. Return Value: This function returns an array with the keys "columns" and "ro 1 min read Like