From cd2f425def45b19d2409c5fb3c1473ef7eb592dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20K=C3=B6hntopp?= Date: Sun, 12 Nov 2000 22:13:46 +0000 Subject: [PATCH] Added stuff on output buffering callbacks. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@35624 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/outcontrol.xml | 48 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/functions/outcontrol.xml b/functions/outcontrol.xml index 2b2eda7933..456e298a61 100644 --- a/functions/outcontrol.xml +++ b/functions/outcontrol.xml @@ -94,7 +94,11 @@ ob_end_flush(); void ob_start - + string + + output_callback + + @@ -110,6 +114,48 @@ ob_end_flush(); ob_end_clean will silently discard the buffer contents. + + 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 ob_end_flush + 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. + + + Output buffers are stackable, that is, you may call + ob_start while another + ob_start is active. Just make + sure that you call ob_end_flush() + the appropriate number of times. If multiple output callback + functions are active, output is being filtered sequentially + through each of them in nesting order. + + + Callback function example + +<?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(); ?> + +?> + + See also ob_get_contents, ob_end_flush,