note 27631 deleted from function.ob-start by sniper

From: Date: Mon, 03 Nov 2003 15:36:52 +0000
Subject: note 27631 deleted from function.ob-start by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-59695@lists.php.net to get a copy of this message
Note Submitter: ricca4u@yahoo.com ---- 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

« previous php.notes (#59695) next »