Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法将空字符串分配给Wordpress中的字符串偏移警告_Wordpress_Warnings - Fatal编程技术网

无法将空字符串分配给Wordpress中的字符串偏移警告

无法将空字符串分配给Wordpress中的字符串偏移警告,wordpress,warnings,Wordpress,Warnings,加载页面时,它会显示以下警告: 警告:无法将空字符串分配给中的字符串偏移量 C:xampp\htdocs\wordpress\smart-m\wp includes\class.wp-scripts.php 第447行 我认为这不是合乎逻辑的问题。可能是wordpress的原因吗? 这是第447行wp-scripts.php文件中的函数 public function localize( $handle, $object_name, $l10n ) { if ( $handle

加载页面时,它会显示以下警告:

警告:无法将空字符串分配给中的字符串偏移量 C:xampp\htdocs\wordpress\smart-m\wp includes\class.wp-scripts.php 第447行

我认为这不是合乎逻辑的问题。可能是wordpress的原因吗? 这是第447行wp-scripts.php文件中的函数

public function localize( $handle, $object_name, $l10n ) {
        if ( $handle === 'jquery' )
            $handle = 'jquery-core';

        if ( is_array($l10n) && isset($l10n['l10n_print_after']) ) { // back compat, preserve the code in 'l10n_print_after' if present
            $after = $l10n['l10n_print_after'];
            unset($l10n['l10n_print_after']);
        }

        foreach ( (array) $l10n as $key => $value ) {
            if ( !is_scalar($value) )
                continue;

            $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
        }

        $script = "var $object_name = " . wp_json_encode( $l10n ) . ';';

        if ( !empty($after) )
            $script .= "\n$after;";

        $data = $this->get_data( $handle, 'data' );

        if ( !empty( $data ) )
            $script = "$data\n$script";

        return $this->add_data( $handle, 'data', $script );
    }

这是WP4.6.*和PHP7.1上出现的问题


请提供您的PHP和WP版本。但是,如果您正在运行WP4.6和PHP7.1,请更新到WP4.7以解决此警告。

您可以删除此代码:

$l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');

在此之前,请复制您的原始文件

您能否添加一个解释,解释为什么这有助于解决问题?可能的副本