Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the benefit of passing a callback to ob_start compared to just processing the result of ob_get_clean()?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COIn the first case, you don't need to do `$result = ob_get_clean();`, you'll do `ob_end_clean();` (calls the callback before cleaning too). Else the second case is yours. If you want to use the first case this way (modifying 2 times result), you'll just add complexity to your app.
      singulars
    2. COThanks @Ninsuo, but I think maybe you didn't understand my code samples properly (I wasn't clear enough in my question), so I have added a bit more context by making them into method calls with identical signatures. The first case isn't modifying the result twice, I don't understand what you mean there, can you clarify how that is the case? Of course I want to use `ob_get_clean()` and not `ob_end_clean()` as that simply discards the contents of the buffer, which I want to keep. I'm asking about using the callback in `ob_start()` vs processing the result "inline" so to speak.
      singulars
    3. COWhile I think that all of this is just a matter of coding style (with Ninsuo correctly pointing out that the callback style can get you a little cleaner code), you should re-evaluate if it is really necessary to fall back to using output buffering for capturing the output. What are you doing in between `ob_start` and `ob_get_clean`? Wouldn't you be able to append the output to a variable in the first place?
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload