有时我们需要页面内容完成生成后一次性输出,或者echo之后马上输出页面内存而不缓存,那么我们就会用到PHP的页面输出缓存控制的相关函数。
PHP页面输出缓存控制函数如下:flush -- 刷新输出缓冲 ob_clean -- Clean (erase) the output buffer ob_end_clean -- Clean (erase) the output buffer and turn off output buffering ob_end_flush -- Flush (send) the output buffer and turn off output buffering ob_flush -- Flush (send) the output buffer ob_get_clean -- Get current buffer contents and delete current output buffer ob_get_contents -- Return the contents of the output buffer ob_get_flush -- Flush the output buffer, return it as a string and turn off output buffering ob_get_length -- Return the length of the output buffer ob_get_level -- Return the nesting level of the output buffering mechanism ob_get_status -- Get status of output buffers ob_gzhandler -- ob_start callback function to gzip output buffer ob_implicit_flush -- Turn implicit flush on/off ob_list_handlers -- List all output handlers in use ob_start -- Turn on output buffering output_add_rewrite_var -- Add URL rewriter values output_reset_rewrite_vars -- Reset URL rewriter values 更加详细的用法见PHP用户手册,下面举一个简单的示例:
PHP 代码