note 36965 added to function.ob-start
| From: | oliver dot no dot spam dot story at anu dot edu dot au | Date: | Wed, 29 Oct 2003 03:47:28 +0000 |
| Subject: | note 36965 added to function.ob-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59453@lists.php.net to get a copy of this message | ||
I have a draft server and live server, and wanted to add a big red marker so that my colleagues
approving draft pages knew which was which.
My solution: an auto-prepended file on my draft server (set in apache configuration) with the
following code:
<?php
function mark_as_draft($page) {
$heading = '<h1 style="color: #D00; text-align:
center">DRAFT</h1>';
$page = ereg_replace('(<body[^>]*>)', '\\1'.$heading, $page);
return $page;
}
ob_start('mark_as_draft');
?>
The ereg_replace() is there because I was having browser rendering problems when I initially tried
outputing the <h1> at the start of the file (ie making the html invalid).
The appropriate apache directive is:
php_value auto_prepend_file /path/to/prepend_file.php
----
Manual Page -- http://www.php.net/manual/en/function.ob-start.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36965
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36965&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36965&report=yes
Search -- http://master.php.net/manage/user-notes.php