note 55271 added to function.include
| From: | IgnacioEsviza at osu1 dot php dot net | Date: | Thu, 28 Jul 2005 21:18:22 +0000 |
| Subject: | note 55271 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92676@lists.php.net to get a copy of this message | ||
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>";
?>
----
Submitter IP: 200.68.106.3
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55271
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55271&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55271&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55271&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55271&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55271&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55271&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55271&report=yes
Search -- http://master.php.net/manage/user-notes.php