note 74020 deleted from function.ob-start by bobby
| From: | bobby@php.net | Date: | Wed, 21 Mar 2007 14:59:05 +0000 |
| Subject: | note 74020 deleted from function.ob-start by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-124671@lists.php.net to get a copy of this message | ||
Note Submitter: ledlincoln
----
Aleksey touched on this earlier, but here's a simple way to set the page title after
you've generated the body content:
<html><head><title>
<?php
function inserttitle($bufin) {
global $title;
$out = $title.$bufin;
return $out;
}
ob_start('inserttitle');
// buffering the body
print "<body><p>this is part of the body\n";
print "<p>another line\n";
// we have established the body before we set the title
$title = "finally set title</title></head>\n";
// inserttitle is called when we flush
ob_end_flush();
// and it has generated good html
?>
</body>
</html>