How do I stop PHP output buffering from eating error messages?

后端 未结 2 700
旧巷少年郎
旧巷少年郎 2021-01-13 02:55

Well, now that I\'ve gotten a bit further into it, I realize that this is a stupid question, and wrong. Turns out that the author of the legacy code I maintain was hi-jackin

2条回答
  •  被撕碎了的回忆
    2021-01-13 03:29

    I've never done this in practice, but this should work:

    You would have to build a wrapper around error_log() that

    1. stores the output you are buffering using ob_get_contents()
    2. erases the output buffer using ob_clean()
    3. writes out the error message and ob_flush()es it
    4. writes back the stored output using echo()

提交回复
热议问题