Added stuff on output buffering callbacks.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@35624 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Kristian Köhntopp 2000-11-12 22:13:46 +00:00
parent 06180443d0
commit cd2f425def

View file

@ -94,7 +94,11 @@ ob_end_flush();
<funcsynopsis>
<funcprototype>
<funcdef>void <function>ob_start</function></funcdef>
<void/>
<paramdef>string
<parameter>
<optional>output_callback</optional>
</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
@ -110,6 +114,48 @@ ob_end_flush();
<function>ob_end_clean</function> will silently discard the
buffer contents.
</para>
<para>
An optional output_callback function may be specified. This
function takes a string as a parameter and returns a string.
The function will be called at <function>ob_end_flush</function>
time and will receive the contents of the output buffer as its
parameter. It must return a new output buffer as a result,
which is what will be printed.
</para>
<para>
Output buffers are stackable, that is, you may call
<function>ob_start</function> while another
<function>ob_start</function> is active. Just make
sure that you call <function>ob_end_flush()</function>
the appropriate number of times. If multiple output callback
functions are active, output is being filtered sequentially
through each of them in nesting order.
</para>
<example>
<title>Callback function example</title>
<programlisting role="php">
&lt;?php
function c($str) {
// Druu Chunusun mut dum Kuntrubuß...
return nl2br(ereg_replace("[aeiou]", "u", $str));
}
function d($str) {
return strip_tags($str);
}
?>
&lt;?php ob_start("c"); ?&gt;
Drei Chinesen mit dem Kontrabaß...
&lt;?php ob_start("d"); ?&gt;
&lt;h1&gt;..saßen auf der Straße und erzählten sich was...&lt;/h1&gt;
&lt;?php ob_end_flush(); ?&gt;
... da kam die Polizei, ja was ist denn das?
&lt;?php ob_end_flush(); ?&gt;
?&gt;
</programlisting>
</example>
<para>
See also <function>ob_get_contents</function>,
<function>ob_end_flush</function>,