mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
06180443d0
commit
cd2f425def
1 changed files with 47 additions and 1 deletions
|
@ -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">
|
||||
<?php
|
||||
function c($str) {
|
||||
// Druu Chunusun mut dum Kuntrubuß...
|
||||
return nl2br(ereg_replace("[aeiou]", "u", $str));
|
||||
}
|
||||
|
||||
function d($str) {
|
||||
return strip_tags($str);
|
||||
}
|
||||
?>
|
||||
|
||||
<?php ob_start("c"); ?>
|
||||
Drei Chinesen mit dem Kontrabaß...
|
||||
<?php ob_start("d"); ?>
|
||||
<h1>..saßen auf der Straße und erzählten sich was...</h1>
|
||||
<?php ob_end_flush(); ?>
|
||||
... da kam die Polizei, ja was ist denn das?
|
||||
<?php ob_end_flush(); ?>
|
||||
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
See also <function>ob_get_contents</function>,
|
||||
<function>ob_end_flush</function>,
|
||||
|
|
Loading…
Reference in a new issue