ob_clean和ob_flush之间的区别?

Ale*_*x V 35 php output-buffering

ob_clean()和之间有什么区别ob_flush()

还有什么区别ob_end_clean()ob_end_flush()?我知道ob_get_clean()并且ob_get_flush()都获得内容和结束输出缓冲.

Ada*_*ner 53

*_clean变种刚清空缓冲区,而*_flush功能打印的内容是在缓冲区(发送内容到输出缓冲).

例:

ob_start();
print "foo";      // This never prints because ob_end_clean just empties
ob_end_clean();   //    the buffer and never prints or returns anything.

ob_start();
print "bar";      // This IS printed, but just not right here.
ob_end_flush();   // It's printed here, because ob_end_flush "prints" what's in
                  // the buffer, rather than returning it
                  //     (unlike the ob_get_* functions)
Run Code Online (Sandbox Code Playgroud)

  • 换句话说,`ob_end_clean()`只是意味着丢弃缓冲区中的所有内容. (4认同)