How to get the length of the output buffer in PHP

1 Answer

0 votes
ob_start();

echo "PHP ";

$ob_len1 = ob_get_length();

echo "Output Buffer";

$ob_len2 = ob_get_length();

ob_end_clean();

echo $ob_len1 . "<br />";
echo $ob_len2;

// "PHP " - 4
// "PHP Output Buffer" - 17

/*
run:
    
4
17 
       
*/

 



answered Jul 14, 2016 by avibootz

Related questions

1 answer 208 views
1 answer 224 views
1 answer 147 views
...