note 27631 added to function.ob-start
| From: | ricca4u at yahoo dot com | Date: | Fri, 13 Dec 2002 15:14:01 +0000 |
| Subject: | note 27631 added to function.ob-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40864@lists.php.net to get a copy of this message | ||
Using an output_callback function with ob_start() I found that sometimes, modifying the parameter
containing the internal buffer in the function itself causes an an unexpected behavior.
Here is an example:
<?php
/**************************
** This doesn't work! **
***************************/
function foo ($string) {
$string = str_replace ("hello", "Hello", $string);
return $string;
}
ob_start ('foo');
...
...
ob_end_flush();
?>
Using a temporary variable seems to work:
/*******************
** This works! **
*******************/
function foo ($string) {
$string2 = $string;
$string2 = str_replace ("hello", "Hello", $string2);
return $string2;
}
However, just appending to the internal buffer doesn't seem to create problems.
Hope this helps
Rik
--
http://www.php.net/manual/en/function.ob-start.php
http://master.php.net/manage/user-notes.php?action=edit+27631
http://master.php.net/manage/user-notes.php?action=delete+27631
http://master.php.net/manage/user-notes.php?action=reject+27631