apache - PHP Warning: Cannot modify header information - headers already sent by -


this question has answer here:

i know has been asked million times can't seem find answer helps mine.

i started new php website , saw in title keeps saying:

warning: cannot modify header information - headers sent (output started @ /customers/e/7/8/andersws.dk/httpd.www/template/index.php:2) in /customers/e/7/8/andersws.dk/httpd.www/template/index.php on line 4

all in file far is:

<!doctype html> <?     if(file_exists('first.run')){         header('location: index.php');     } ?> <html>     <head>         <meta charset="utf-8">         <title></title>     </head>     <body>         <?php         // put code here         ?>     </body> </html> 

so can't see i'm doing wrong.

it's because specified doctype before header. cannot output header after payload has been sent. change to:

<?     if(file_exists('first.run')){         header('location: index.php');     } ?> <!doctype html>  <html>     <head>         <meta charset="utf-8">         <title></title>     </head>     <body>      </body> </html> 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -