Error - Warning: Cannot modify header information - headers already sent by

后端 未结 4 479
北海茫月
北海茫月 2021-01-01 02:28

Error:

Warning: Cannot modify header information - headers already sent by (output started at /home/ya3mblog/public_html/wp-login.php:59) in /home

相关标签:
4条回答
  • 2021-01-01 03:11

    Add this code in wp-config.php on the first line:

    ob_start();
    error_reporting(0);
    
    0 讨论(0)
  • 2021-01-01 03:13

    In my case happened because from the Wordpress Rest API in the functions I was ending the job by doing

    echo json_encode($result);
    

    instead of the simple:

    return $result;
    

    Changing that.. worked!

    0 讨论(0)
  • 2021-01-01 03:17

    See How_do_I_solve_the_Headers_already_sent_warning_problem? > FAQ Troubleshooting « WordPress Codex

    (This error) is usually because there are spaces, new lines, or other stuff before an opening <?php tag or after a closing ?> tag, typically in wp-config.php.

    Open the file with a plain text editor (like Notepad or BBEdit) and clear out the white space. Check that the very first characters are <?php and the very last characters are either NOT a PHP closing tag, or a closing tag ?> with no blank lines or spaces after it. (FYI, a PHP file can run fine without the closing ?> tag.)

    When saving, be sure the file encoding is not UTF-8 BOM but plain UTF-8 or any without the BOM suffix.

    And:

    This could be true about some other file too, so please check the error message, as it will list the specific file name where the error occurred. Replacing the faulty file with one from your most recent backup or one from a fresh WordPress download is your best bet.

    If the error message states: Warning: Cannot modify header information - headers already sent by (output started at /path/blog/wp-config.php:34) in /path/blog/wp-login.php on line 42, then the problem is at line #34 of wp-config.php, not line #42 of wp-login.php. In this scenario, line #42 of wp-login.php is the victim. It is being affected by the excess whitespace at line #34 of wp-config.php.

    If the error message states: Warning: Cannot modify header information - headers already sent by (output started at /path/wp-admin/admin-header.php:8) in /path/wp-admin/post.php on line 569, then the problem is at line #8 of admin-header.php, not line #569 of post.php. In this scenario, line #569 of post.php is the victim. It is being affected by the excess whitespace at line #8 of admin-header.php.

    0 讨论(0)
  • remove the excess blankspace /home/ya3mblog/public_html/wp-login.php in line 59.

    0 讨论(0)
提交回复
热议问题