Налаштування під час виконання

На поведінку цих функцій випливають налаштування в php.ini.

Output Control configuration options
Назва Початково Де можна змінювати Журнал змін
output_buffering "0" INI_PERDIR  
output_handler null INI_PERDIR  
implicit_flush "0" INI_ALL  
url_rewriter.tags "form=" INI_ALL As of PHP 7.1.0, this INI setting only affects output_add_rewrite_var(). Prior to PHP 7.1.0, this INI setting enabled transparent session id support (see session.trans_sid_tags).
url_rewriter.hosts $_SERVER['HTTP_HOST'] is used as default. INI_ALL Available as of PHP 7.1.0
Докладніша інформація та визначення режимів INI_* на сторінці Де можна встановлювати параметри конфігурації.

Тут є коротке пояснення директив конфігурації.

output_buffering bool/int

Output buffering for all files can be enabled by setting this directive to "On". To limit the size of the buffer, a number/quantity corresponding to the maximum numbers of bytes allowed can be used instead of "On" for the value of this directive. For example output_buffering=4096. This directive is always Off in PHP-CLI.

output_handler string

The output of scripts can be redirected to a function. For example setting output_handler to mb_output_handler(), character encoding will be transparently converted to the specified encoding. Setting any output handler automatically turns on output buffering.

Зауваження:

mb_output_handler() and ob_iconv_handler() cannot be used together and ob_gzhandler() and zlib.output_compression cannot be used with any of the following: mb_output_handler(), ob_gzhandler(), zlib.output_compression, the 'URL-Rewriter' handler (see session.use_trans_sid and output_add_rewrite_var()).

Зауваження:

Only built-in functions can be used with this directive. For user defined functions, use ob_start().

implicit_flush bool

false by default. Changing this to true tells PHP to tell the output layer to flush itself automatically after every output block. This is equivalent to calling the PHP function flush() after each and every call to any function producing output (such as print or echo) and each and every HTML block.

When using PHP within an web environment, turning this option on has serious performance implications and is generally recommended for debugging purposes only. This value defaults to true when operating under the CLI SAPI.

See also ob_implicit_flush().

url_rewriter.tags string
url_rewriter.tags specifies HTML tags and attributes in which URLs are rewritten by output_add_rewrite_var() values. Defaults to "form=". Adding "form=" or any form attribute will add a hidden input element to the form with a name and value attribute for each name-value pair passed to output_add_rewrite_var().
Застереження

Adding the same tag more than once to url_rewriter.tags will only use the first occurence during the URL rewriting process.

Зауваження: Prior to PHP 7.1.0, url_rewriter.tags was used to specify session.trans_sid_tags.

url_rewriter.hosts string
url_rewriter.hosts specifies which hosts are rewritten to include output_add_rewrite_var() values. Defaults to $_SERVER['HTTP_HOST']. Multiple hosts can be specified by a comma separated list that does not include spaces. For example "php.net,wiki.php.net,bugs.php.net".

add a note

User Contributed Notes 1 note

up
5
support at losalgendesign dot com
11 years ago
Using "OFF" or no value on output_buffering will disable header modifications, like redirects or content-type or content-disposition resulting in the error we commonly attribute to output before header modifications:

Warning: Cannot modify header information - headers already sent by (output started at C:\PATH\filename.php:1) C:\PATH\filename.php on line 1

Example code with output_buffering = OFF which results in this behavior. Changing it to "ON" or giving it a value will likely cause normal behavior.

<?php header("Location: http://www.php.net"); ?>

or

<?php header("Content-Type: text/Calendar"); ?>
<?php header
("Content-Disposition: inline; filename=appointment.ics"); ?>
To Top