开发者

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 another ob_start() is active. Just make sure that you call ob_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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜