PHP I want an own cache system (output buffer)
According to GET parameters, I want to save the output HTML and save to my own cache. Next time it's called, load the cache. It sounds easy to use ob_start()
and o开发者_如何学Cb_get_contents()
but what if the other running scripts in between use this too? It spoils the "original" output buffering, right?
How to globally save the output?
To quote the PHP manual for ob_start:
Output buffers are stackable, that is, you may call
ob_start()
while anotherob_start()
is active. Just make sure that you callob_end_flush()
the appropriate number of times.
In other words: No, it doesn't spoil the original output buffering; buffering can be nested. You can also use ob_get_flush()
instead of ob_end_flush()
to "stop" buffering.
精彩评论