note 55271 deleted from function.include by aidan

From: Date: Sat, 15 Apr 2006 16:34:30 +0000
Subject: note 55271 deleted from function.include by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-108163@lists.php.net to get a copy of this message
Note Submitter: Ignacio Esviza ---- Just a better implementation of the function posted before... A way to assign an include's output to a variable (without actually write it to the buffer) in order to make some process, or just print it more than one time, or something more usefull. File "test.php": <?php ob_start(); $myOutput = getIncludeOutput("inc.test2.php"); echo "Here is the output:<br>"; echo str_to_upper( $myOutput )."<br>"; echo "And here is again the output:<br>"; echo str_to_lower( $myOutput )."<br>"; function getIncludeOutput($path){ /* save the current buffer */ $buffer = ob_get_contents(); /* write the include */ include $path; $output = substr($buffer,strlen($buffer)); /* restore the original buffer */ ob_clean(); echo $buffer; return $output; } ?> File "inc.test2.php": <?php echo "<i>Hello, World!</i><br>"; ?>

« previous php.notes (#108163) next »