So I know you can use output buffer. The problem right now is, I am using a function in a WordPress plugin and it is automatically and it automatically outputs the return. However, I want to check the return to see if it is false or returning my data.
I have tried:
if( function_name() ) {
}
$name = function_name();
I can still see the output in those situations, which I why I wanted to suppress it and do some checks first. I don’t want to edit the core function of the plugin, but I will as a last resort. Is there a better work around?
Yes. It can be done like this:
Have a look here for more information about output control functions.
Also, instead of using
ob_flush
andob_end_clean
you could useob_get_clean
.First, capture the output and return value of the function.
Next, decide whether or not you want to output it.
You weren’t clear what you wanted to do with the return value if it wasn’t
false
or if it was actually the output of the function that you wanted to send to the page.