note 40318 added to function.headers-sent
| From: | php at fufachew dot REMOVEME dot com | Date: | Sat, 28 Feb 2004 16:26:54 +0000 |
| Subject: | note 40318 added to function.headers-sent | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65939@lists.php.net to get a copy of this message | ||
RE: antti at haapakangas dot net's post
I've changed the code so $_SERVER['SERVER_NAME'] is used if
$_SERVER['HTTP_HOST'] is not set. $_SERVER['SERVER_NAME'] doesn't meet my
needs, but I suppose it's good to fall back on it. I've also fixed a problem in the meta
refresh line - it was missing the "url=" part of the content attribute.
<?php
function server_url()
{
$proto = "http" .
((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ==
"on") ? "s" : "") . "://";
$server = isset($_SERVER['HTTP_HOST']) ?
$_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
return $proto . $server;
}
function redirect_rel($relative_url)
{
$url = server_url() . dirname($_SERVER['PHP_SELF']) . "/" . $relative_url;
if (!headers_sent())
{
header("Location: $url");
}
else
{
echo "<meta http-equiv=\"refresh\"
content=\"0;url=$url\">\r\n";
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.headers-sent.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40318
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40318&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40318&report=yes
Search -- http://master.php.net/manage/user-notes.php