LXXVIII. Output Control Function
Introduction
Output control functions can be used to control the output of the script. These functions are useful in some special cases, especially after the information has been output, and then want to send head information to the browser. The output control function does not act on header information sent by the header () or setcookie () function, but only affects information similar to the ECHO () function output and embedded between PHP code.
demand
Support for this expansion module without external library files.
installation
These functions are used as part of the PHP core without being installed.
Runtime configuration
The behavior of these functions is affected by the global configuration file php.ini.
Table 1. Output Control Configuration Options
Name Default Scope Output_Buffering "0" PHP_INI_PERDIR | PHP_INI_SYSTEMOUTPUT_HANDLERNULLLPHP_INI_PERDIR | PHP_INI_SYSTEMPLICIT_FLUSH "0" PHP_INI_PERDIR | PHP_INI_SYSTEM
More details and explanations for constant PHP_INI_ *
INI_SET ().
The following is a brief explanation of this configuration option.
Output_buffering
Boolean /
Integer
When this tag is set to ON, output control will be used in all scripts. If you want to limit the maximum value of the output buffer, the tag can be set to the maximum number of bytes (for example, Output_Buffering = 4096).
Output_handler
String
This tag can redirect all the scripts to a function. For example, when setting Output_Handler to MB_OUTPUT_HANDLER (), the code will be modified to the specified encoding. Any processing function set will buffer the auto processing output.
Note: You cannot use MB_OUTPUT_HANDLER () and ob_inconv_handler (), and ob_gzhandler () and zlib.output_compression cannot be used at the same time.
IMPLICIT_FLUSH
Boolean
The default is false. If the tag is changed to True, the PHP will make the output layer, and then automatically refreshed after each section of the information block. This is equivalent to calling the flush () function in the PHP after each HTML block, each HTML block is used.
When using PHP in a web environment, open this option has a serious impact on the performance of the program, usually it is recommended when commissioning. In the execution mode of the CLI SAPI, the tag defaults to TRUE.
See ob_implicit_flush ().
Resource Type
The expansion module does not define any resource type.
Predefined constant
The expansion module does not define any constant.
example
Example 1. Output control example
phpob_start (); Echo "Hello / N"; SetCookie ("Cookiename", "Cookiedata"); OB_END_FLUSH ();?>>
In the above example, the function echo () output information will be saved in the output buffer until the OB_END_FLUSH () function is called. Like expectations, the setCookie () function stores cookies when it does not cause errors. (Normally, after the data output is output, it is not normal to send head information to the browser.)
Note: When upgrading from PHP 4.1 (including 4.2) to 4.3, due to earlier versions of bugs, it is necessary to ensure that ImplicT_flush is set to OFF in php.ini, otherwise all information processed by the ob_start () function will be directly output. Related reference
Related functions: header () and setCookie ().
table of Contents
Flush - Flush the Output Buffer
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_GZHANDAL - OB_START CALLBACK FUNCTION TO GZIP OUTPUT BUFFER
OB_IMPLICIT_FLUSH - Turn Implicit Flush ON / OFF
OB_LIST_HANDLERS - List All Output Handlers in Uses
OB_Start - Turn ON Output Buffering
Output_add_rewrite_var - Add URL Rewriter Values
Output_reset_rewrite_vars - Reset URL Rewriter Values