开发者

Cannot modify header information - headers already sent [duplicate]

开发者 https://www.devze.com 2023-04-09 04:19 出处:网络
This question already has answers here: How to fix "Headers already sent" error in PHP (11 answers)
This question already has answers here: How to fix "Headers already sent" error in PHP (11 answers) Reference - What does this error mean in PHP? (38 answers) Closed 10 years ago.

In my (WordPress) 开发者_JS百科functions when I try to change Code 1 to Code 2 I get this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/consumer/public_html/themeforward.com/demo2/wp-content/themes/Tutles/functions.php:1) in /home/consumer/public_html/themeforward.com/demo2/wp-admin/theme-editor.php on line 99

Code 1

array( 
   "name" => "Custom CSS",  
   "desc" => "Want to add any custom CSS code? Put in here, and the rest is taken care of. This overrides any other stylesheets. eg: a.button{color:green}",  
   "id" => $shortname."_custom_css",  
   "type" => "textarea",  
   "std" => ""
),      

Code 2

array( 
    "name" => "Link Color",  
    "desc" => "Want to add any custom CSS code? Put in here, and the rest is taken care of. This overrides any other stylesheets. eg: a.button{color:green}",  
    "id" => $shortname."_link_color",  
    "type" => "textarea",  
    "std" => ""
),      

Lines 89 - 102:

// don't allow template files in subdirectories
if (false !== strpos($basename, '/')) continue;

$template_data = implode('', file( $template ));

$name = '';
if (preg_match( '|Single Post Template:(.*)$|mi', $template_data, $name))
    $name = _cleanup_header_comment($name[1]);

if (!empty($name)) {
    if(basename($template) != basename(__FILE__))
        $post_templates[trim($name)] = $basename;
}

I am completely confused as to how to fix this.


You probably created a file (or edited a file). I assume functions.php?

There probably is a whitespace in that file, being it on the beginning of the file, or at the end.

To prevent whitespaces from happening on the end of the file, just remove the ?> tag. Also remove any whitespace at the beginning of every file


You have blank space or BOM before your first <?php tag. Remove it


Is your php file encoded in UTF8 without BOM ? If not, encode it this way and try again. maybe this is way you get the error


When using certain encodings some editors add "dtž" at the beginning of the file (which is not shown in the editor.

0

精彩评论

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