note 63293 rejected from function.ob-start by bjori
| From: | bjori@php.net | Date: | Sat, 18 Mar 2006 17:58:19 +0000 |
| Subject: | note 63293 rejected from function.ob-start by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-106042@lists.php.net to get a copy of this message | ||
Note Submitter: redscourge nospam at gmail dot com
----
i am trying to use object oriented code which has an HTMLBegin method and an HTMLEnd method, and
include this object into some pages on my site, and i wrap these functions outputs around content on
each page. this method takes in a few variables such as the page title, and it constructs all the
top HTML code to the opening of the body tag, to save me some code, and the end method takes over
and closes all HTML elements including the body.
my problem is, i use ob_start at the top of the HTMLBegin before any output is sent, and i flush the
buffer at the end of the HTMLEnd function, yet its not working!
heres a sample of the html in the first method:
<?php
function HTMLBegin(variables){
ob_start("");
(bunch of other code)
//close the php so i can output some html here
?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title><?php echo $title;?></title>
...
//reopen php tags and close the function, carry out rest of code, etc
<?php
}
?>
at the line where i attempt to output the title, output buffering is not apparently working!
if i make a page like this:
<?php
(include and instantiate the object)
$instance->HTMLBegin(variables);
page content
<?php
header("Location: http://www.example.com/");
?>
$instance->HTMLEnd();
i get errors and it doesnt send the headers!
PHP Warning: Cannot modify header information - headers already sent by (output started at...
PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in...
the headers are "already sent" at the line where i output $title, and the second error
occurs when i try to flush the output buffer at the bottom.
it is almost as if output buffering is not taking place at all, yet, the error takes place after i
outout the value only!
this same exact code used to work PERFECTLY before i upgraded to php 5.1.2 or whatever newest
version is, i was using php 5.0.4 before i upgraded.
can ANYONE tell me exactly what is going wrong, and how i might fix this problem?
it seems to be very hard to find out exactly what changes occur between php versions, and the manual
doesnt seem to document why this happens anywhere.