开发者

Header Problem though header is not sent before [duplicate]

This question already has answers here: Warning: Cannot modify header information [duplicate] (5 answers) How to fix "Headers already sent" error in PHP (11 answers) Closed 10 years ago.

I know before sending their should not be any printing statement on the screen. and I haven't did that in my code. Their is no echo statement no print s开发者_运维知识库tatement.

warning Cannot modify header information - headers already sent by (output started at /home/oxfordmo/public_html/php/user/header.php:18) in /home/oxfordmo/public_html/php/user/index.php on line 21

Its showing error in header file.

Indexfile line 21

header("location:user.php?f=".base64_encode($_SESSION['firstname'])."&l=".base64_encode($_SESSION['lastname']));

and header file 15-20

<div id="wrapperheader">
  <div id="menu">
   <ul>
    <li class="active"><a href="">Company</a></li>
    <li><a href="">Services</a></li>
    <li><a href="">Gallery</a></li>


Make sure you have no output before the header - this includes, but is not limited to, HTML output outside of the PHP block, output from includes you might do. Also check for unseen whitespace in includes after their closing ?> (many just leave them out for this exact reason).


It seems like you're including that header.php file before sending the headers, that is, you have something like this:

include( header.php );
...
header( 'Location: ...' );

If this is the case, you have to move the header command to before including the file. Anything that outputs page content is not allowed before sending a header. That includes outputting "raw" HTML outside PHP tags (... ?> <html> <?php ...)


Yes there is HTML output in line 18. You can not use the header function after HTML output has been created. That simple it is.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜