简体   繁体   English

警告:无法修改已发送的标头信息标头(输出始于(/themes/kaboodle/functions/admin-setup.php

[英]Warning:Cannot modify header information-headers already sent by (output started at (/themes/kaboodle/functions/admin-setup.php

Warning Message : 警告信息 :

Warning:Cannot modify header information-headers already sent by (output started at (/themes/kaboodle/functions/admin-setup.php:174) in /wp-includes/pluggable.php on line 940 警告:无法在第940行/wp-includes/pluggable.php中修改已经由发送的标题信息标题(输出从(/themes/kaboodle/functions/admin-setup.php:174开始)

There is seems to an warning in line number 174 of file admin-setup.php which is written as below : 文件admin-setup.php第174行似乎出现了警告,内容如下:

echo '<link href="'. get_template_directory_uri() . '/styles/'. $style . '.css" rel="stylesheet" type="text/css" />' . "\n\n";

i have checked the admin-setup file with any hidden whitespace on php quotes() but still error is persisting. 我已经检查了php quotes()上任何隐藏的空格的admin-setup文件,但错误仍然存​​在。 Could anyone help me out to solve this warning message. 谁能帮助我解决此警告消息。 for reference i am putting lines below those are required to check for such error. 供参考,我将下面的行放在检查此类错误的位置。

Line 174 : 174行:

*echo '<link href="'. get_template_directory_uri() . '/styles/'. $style . '.css" rel="stylesheet" type="text/css" />' . "\n\n";*

Re-direct function written as: 重定向功能写为:

function woo_themeoptions_redirect () {
    // Do redirect
    header('Location: ' . admin_url() . 'admin.php?page=woothemes');
} // End woo_themeoptions_redirect()

First, you should use wp_enqueue_style to add styles, like so 首先,您应该使用wp_enqueue_style添加样式,如下所示

function my_styles_function() 
{
    wp_enqueue_style( 'my-style-name', get_template_directory_uri() . 'somestyle.css");
}

add_action( 'wp_enqueue_scripts', 'my_styles_function' );

Second, redirects should be done with wp_safe_redirect on admin_init or init to ensure there is no output before redirect is supposed to happen. 其次,应该使用admin_initinit上的wp_safe_redirect进行重定向,以确保在应该进行重定向之前没有输出。 For example 例如

function my_redirect()
{
       wp_safe_redirect('link_here');
}

add_action('admin_init', 'my_redirect'); // for admin
add_action('init', 'my_redirect'); // for frontend

Also, what is the point of echoing style before redirecting? 另外,重定向之前回显样式的意义是什么?

yes you can solve it the mistakes to that error are 是的,您可以解决该错误的错误是

1.spaces before 1.之前的空格

<?php ?>

2.html contents before header 2.html标头之前的内容

3.anything echoed before header 3.标题前回显的任何内容

you have to remove those 你必须删除那些

but even after that it show you the same error you can use javascript redirect like this 但即使在此之后,它也会向您显示相同的错误,您可以像这样使用javascript重定向

<script type="text/javascript">
  window.location.assign('your desired location');
</script>
 header('Location: ' . admin_url() . 'admin.php?page=woothemes');

you can not use that, after you echoed anything. 在回声之后,您将无法使用该功能。 The echo sends the header (as most servers send their output in pieces) and therfore you can't modify it anymore with a header() command. echo发送标头(大多数服务器将其输出分段发送),因此您无法再使用header()命令对其进行修改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP - 无法修改标头信息 - 标头已由(输出开始于 - PHP - cannot modify header information - headers already sent by (output started at PHP 重现警告“无法修改 header 信息 - 标头已由(输出开始于...”与 XAMPP 8..1.1 - PHP reproduce warning "Cannot modify header information - headers already sent by (output started at... " with XAMPP 8..1.1 为什么收到警告:无法修改标头信息-标头已经发送过(输出从...开始)? - Why am I getting Warning: Cannot modify header information - headers already sent by (output started at …)? 在CSV下载期间-警告:无法修改标头信息-已发送的标头(输出始于 - During CSV downloading - Warning: Cannot modify header information - headers already sent by (output started at 无法修改标头信息-输出已发送的标头已从/home/nyehfdcj/public_html/application/controllers/admin/Login.php:16开始 - Cannot modify header information - headers already sent by output started at /home/nyehfdcj/public_html/application/controllers/admin/Login.php:16 警告:无法修改标题信息 - 标题已在 wordpress 中发送 - Warning: Cannot modify header information - headers already sent by in wordpress 如何删除警告无法修改标头信息-标头已发送 - How to remove warning Cannot modify header information - headers already sent by 警告:无法修改标头信息-标头已发送 - Warning: Cannot modify header information - headers already sent by 关于警告的奇怪错误:无法修改标题信息-没有空格PHP时已经发送的标题 - Strange error regarding Warning: Cannot modify header information - headers already sent by when there is no white space PHP Wordpress提要:PHP警告无法修改标题信息-标题已发送 - Wordpress Feeds: PHP Warning Cannot modify header information - headers already sent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM