You are here: Re: warning header("Location: file.php") « All PHP « IT news, forums, messages
Re: warning header("Location: file.php")

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация