Best ?php header format

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 4, 2011   (RSS)

By macwebster - March 3, 2011

I recently upgraded an older cmsb site and I noticed that when I generated new pages the opening code was:

?php header('Content-type: text/html; charset=utf-8'); ?>
<?php and so forth.

my older pages started straight off with <?php

As I am adding the code generator code to Dreamweaver templates, I already have the usual meta tag with:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

When testing my pages, I see the warning message:

<br />
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/straffor/public_html/beta/ecdev/ecdev_vision.php:2) in <b>/home/straffor/public_html/beta/ecdev/ecdev_vision.php</b> on line <b>2</b><br />

Can you explain what's going on with the php headers or am I getting the warning from another cause?

http://strafford.org/beta/ecdev/ecdev_vision.php

I know that when I remove ?php header('Content-type: text/html; charset=utf-8'); ?> the warning goes away -- on this page.

However, on some other pages I'm developing, they display properly with the php header.

can you explain what's going on? thanks in advance

J

Re: [Dave] Best ?php header format

By macwebster - March 4, 2011

Dave,

That's great to know about the inconsistent application of a specified charset. Thank you for making this clear.

And I had been using some html comments at the top of the page to remind myself to add the php headers on my templates. There were definitely artifacts of spaces, etc. that were causing the error messages.

another happy cmsb camper, J