ob_start and ob_get_contents buffering problem
| From: | Dasdan | Date: | Fri, 07 Oct 2005 07:03:27 +0000 |
| Subject: | ob_start and ob_get_contents buffering problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-223726@lists.php.net to get a copy of this message | ||
question:
I try to buffer the output of the 'system/views/main.php' into $contents.
and then do a print.
Problem is that the contents of the system/views/main.php are printed 2
times.
Someone who can explain me?
following the contents of testfile.php and main.php, php.ini settings
concerning ob_ ... functions and the output of the script.
Thanks in advance,
Kevin Wood
http://www.dasdan.be
<?php
// testfile.php
ob_start();
include 'system/views/main.php';
$contents = ob_get_contents();
print 'no output above normally ??? :(';
print $contents;
?>
<?php
// file :system/views/main.php
print <<<P1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>The Task List</title>
</head>
<body>
<div>
<h3>test</h3>
<p>
</body>
</html>
P1;
?>
php.ini settings
....
output_buffering = Off
output_handler =
zlib.output_compression = Off
implicit_flush = Off
....
the output :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>The Task List</title>
</head>
<body>
<div>
<h3>test</h3>
<p>
</body>
</html>no output above normally ??? :(<!DOCTYPE HTML PUBLIC "-//W3C//DTD
XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>The Task List</title>
</head>
<body>
<div>
<h3>test</h3>
<p>
</body>
</html>