翻过高山走不出你
ob是output buffering的简称,就是输出缓冲区。如果使用了ob_start函数,那么之后的输出内容(echo等)就不进行实际输出,而是存入缓冲区里面,随后可以使用ob_flush实际输出、ob_clean删除、ob_get_contents获得内容保存到静态文件等。使用输出缓冲区有两个主要的好处:一是可以在输出一些内容之后在设置header(例如cookie等),使得程序设计的逻辑性变得简单;二是可以对缓冲区里面的输出内容撤销、删除、压缩、保存到文件等操作。相关的操作是使用一系列的ob_函数来实现的,常用的有下面这些,通过函数名称可以猜测其功能,需要获得详细帮助可以查看文档或者百度搜索:ob_clean — Clean (erase) the output bufferob_end_clean — Clean (erase) the output buffer and turn off output bufferingob_end_flush — Flush (send) the output buffer and turn off output bufferingob_flush — Flush (send) the output bufferob_get_clean — Get current buffer contents and delete current output bufferob_get_contents — Return the contents of the output bufferob_get_flush — Flush the output buffer, return it as a string and turn off output bufferingob_get_length — Return the length of the output bufferob_get_level — Return the nesting level of the output buffering mechanismob_get_status — Get status of output buffersob_gzhandler — ob_start callback function to gzip output bufferob_implicit_flush — Turn implicit flush on/offob_list_handlers — List all output handlers in useob_start — Turn on output bufferingoutput_add_rewrite_var — Add URL rewriter valuesoutput_reset_rewrite_vars — Reset URL rewriter values