note 54159 rejected from function.ob-start by mazzanet
| From: | mazzanet@php.net | Date: | Sat, 25 Jun 2005 08:58:23 +0000 |
| Subject: | note 54159 rejected from function.ob-start by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-90937@lists.php.net to get a copy of this message | ||
Note Submitter: patrickSPAMNO at pretendsoftware dot com
----
I couldn't get the following code to work:
<?php
function ob_callback($buffer)
{
$buffer .= file_get_contents('template/footer.html');
return $buffer;
}
?>
After some fiddling I came up with this:
<?php
$footer_html = file_get_contents('template/footer.html');
function ob_callback($buffer)
{
global $footer_html;
$buffer .= $footer_html;
return $buffer;
}
?>
Not sure why file_get_contents() won't work inside the callback function, perhaps because of
some silliness with the function writing directly to the buffer, even though it should be returning
a string (which is does in other cases). Even more perplexing:
<?php
function ob_callback($buffer)
{
$buffer .= var_export(file_get_contents('template/footer.html'),true);
return $buffer;
}
?>
Returns error: Fatal error: var_export(): Cannot use output buffering in output buffering display
handlers in c:\pretend\pub_html\_tests\iwantmuscle\funcs.inc.php on line 920
So, it's also impossible for me to examine the return value of file_get_contents() in this case
as well.
Anyone have any ideas on this? (using 4.3.10 on Apache 1.3.27 offline development server).