Posted by J.O. Aho on 07/16/06 03:05
Shearer wrote:
> Why if I use warning header("Location: file.php") i had this warning?
> Warning: Cannot modify header information - headers already sent by
>
>
There is a space/tab (whitespace) or something else that has been outputted
before you use your header(), it's not allowed to output anything before a
header().
--- example whitespace ---
<?PHP
header("Location: file.php");
?>
--- eof ---
--- example HTML output ---
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<?PHP
header("Location: file.php");
?>
--- eof ---
--- example echo to early ---
<?PHP
if(true) {
echo "Hello";
}
header("Location: file.php");
?>
--- eof ---
--- ok use of header ---
<?PHP
if(true) {
header("Location: file.php");
exit;
}
echo "Hello";
?>
--- eof ---
Only the last one will work.
//Aho
Navigation:
[Reply to this message]
|