解决wordpress使用wp_redirect函数出现Warning: Cannot modify header information – headers already sent by (output started at…的方法
网站文章 2026-09-21 07:38:37 4 0

php中使用重定向跳转时,“Warning: Cannot modify header information – headers already sent by (output started at…”是常见的错误提醒,出现该错误的原因是跳转函数前有包括回车、空格、换行的输出,解决方法是使用ob_start()函数打开缓冲区,使用跳转前的输入进入缓冲区而不会立即输出,避免这个错误提醒。近两天博客吧制作的wordpress主题中出现该提示,解决方法是在主题functions.php文件中使用ob_start()函数。

在出现该错误的主题functions.php文件添加代码:

1
2
3
4
add_action('init', 'do_output_buffer');
function do_output_buffer() {
    ob_start();
}

方法来自:http://stackoverflow.com/questions/7381661/cannot-modify-header-information-headers-already-sent-by-wordpress-issue#answer-7461813

 

文章说明
本文标签:
©版权声明
本站提供的一切软件、教程和游戏辅助仅限用于娱乐和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络收集,版权争议与本站无关。如有侵权请邮件与我们联系处理。敬请谅解!6594404@qq.com