我在开发插件中遇到了此错误。
在本地主机中工作正常,但在远程服务器中失败,并显示:
警告:无法修改标头信息 - 标头已由 发送 (输出开始于 /path_wordpress/public_html/wp-admin/include/template.php:1657) in /path_wordpress/public_html/wp-include/pluggable.php 在第 866 行
我已经删除了文件开头和结尾前后的所有空格(此错误的常见原因),并且不涉及会话。
可能还有什么其他原因?
===
编辑 1
WP-ADMIN/INCLUDE/TEMPLATE.php:
$attributes = '';
if ( is_array( $other_attributes ) ) {
foreach ( $other_attributes as $attribute => $value ) { // line 1657
$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
}
} else if ( !empty( $other_attributes ) ) { // Attributes provided as a string
$attributes = $other_attributes;
}
===
编辑2:
WP-INCLUDE/PLUGGABLE.php:
if ( !function_exists('wp_redirect') ) :
/**
* Redirects to another page.
*
* @since 1.5.1
* @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
*
* @param string $location The path to redirect to
* @param int $status Status code to use
* @return bool False if $location is not set
*/ // line 866
function wp_redirect($location, $status = 302) {
global $is_IIS;
无法修改标头信息通常在输出某些 html 后尝试使用 header() 或重定向函数时发生。它不太可能在 Wordpress 本机代码文件之一中,因此请检查您可能编写的一些尝试重定向页面的自定义代码。
参考: http://php.net/manual/en/function.header.php