Re[2]: [PHP] Problem with header
| From: | Tom Rogers | Date: | Thu, 25 Mar 2004 04:14:13 +0000 |
| Subject: | Re[2]: [PHP] Problem with header | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-181439@lists.php.net to get a copy of this message | ||
Hi,
TR> Any whitespace in any file before the <?php will cause data to be sent
TR> to the browser forcing the headers to be sent. So make sure the first
TR> line of your page has <?php and it is a good idea to drop the ?> from
TR> included pages as there may be blank lines following which are just as
TR> bad. So the rule is, header() can go anywhere but before any output to
TR> the browser.
TR> --
TR> regards,
TR> Tom
One other little rule: get into the habit of putting the full url in
location, it will save you grief down the line :)
To redirect to the same page for example
$url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"];
header("Location: $url");
--
regards,
Tom