Is it possible to determine, whether current code output is being buffered in PHP?
Is there a method to determine, whether the echo/print in a random place in a file is being buffer开发者_开发知识库ed with ob_start
? Thanks
ob_get_level()
will return the current output buffering level (the number of output buffers active, since you can call ob_start()
multiple times in a row), so a return value of 0 means no output buffering is active
You can use the ob_get_level()
function:
<?php
if(ob_get_level() > 0) {
// output buffering active
}
Yes there is...
See ob_get_level()
:
if (ob_get_level() > 0) {
//Output Buffering Is Active!
}
But be sure to read the comments on that page for insight as to what's going on, as certain php.ini
settings can set a output buffer from before the start of the script...
You could use ob_get_clean()
to see what's hiding inside that buffer.
精彩评论