00 Votes

PHP: Data Size of Output Buffering

Question by Guest | 2015-02-01 at 11:12

I am using output buffering in PHP to be able to get some data for further processing.

Up to now, I am using the functions ob_start(), ob_get_contents() and ob_end_clean() similar like this:

ob_start();

// create data

$data = ob_get_contents();

ob_end_clean();

As you can see, I am storing the created data in the variable $data.

However, what is missing here, is some function to retrieve or determine the size of the created data/the current internal buffer. However, I need this information between ob_start() and ob_end_clean(). Is there any function for that in PHP?

ReplyPositiveNegative
0Best Answer0 Votes

You are searching for the function ob_get_length().

I have extended your example a little bit:

ob_start();
 
// create data
 
$data = ob_get_contents();
$size = ob_get_length();
 
ob_end_clean();

Here, we are storing the data into $data and the data size into $size.
2015-02-02 at 15:37

ReplyPositive Negative
Reply

Related Topics

PHP: Current Date and Time

Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.