0

As mentioned in PHP Manual:

Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP

Then why does the following code run without any error in localhost? I am using wamp server with PHP version 5.2.5 and Apache version 2.2.6. I am curious to know the reason why I am not getting any error message. Thanks!

<html>
 <body>
  <div>
   some error
  </div>
 </body>
</html>
<?php 
 header('Location: http://google.com/');
?>
JSON C11
  • 11,272
  • 7
  • 78
  • 65
Parveez Ahmed
  • 1,325
  • 4
  • 17
  • 28
  • 1
    possible duplicate of [How to get useful error messages in PHP?](http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php) – GoBusto Apr 11 '15 at 08:49
  • Also, if the redirect does work it could be that your setup is buffering the output so that the headers have not been sent yet. That will likely break on any production server. – jeroen Apr 11 '15 at 09:04
  • There is no error because no output is *sent*, it doesn't matter if output is written as long as it is not sent. – Jimmy T. Apr 11 '15 at 09:07

0 Answers0