Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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
Php 警告:非法字符串偏移量';尺寸';而不是致命的错误_Php_String_Wordpress - Fatal编程技术网

Php 警告:非法字符串偏移量';尺寸';而不是致命的错误

Php 警告:非法字符串偏移量';尺寸';而不是致命的错误,php,string,wordpress,Php,String,Wordpress,警告:第591行/home/liveep5/public_html/wp content/plugins/plugin/inc/tools.php中的非法字符串偏移量“size” $attachment_metadata['sizes']['croped-image-' . $width . '-' . $height] = array( 'file' => $pathinfo['basename'], 'width' =&

警告:第591行/home/liveep5/public_html/wp content/plugins/plugin/inc/tools.php中的非法字符串偏移量“size”

$attachment_metadata['sizes']['croped-image-' . $width . '-' . $height] = array(
        'file'          => $pathinfo['basename'],
        'width'         => $width,
        'height'        => $height,
        'mime-type'     => get_post_mime_type($attachment_id)
    );
    // wp update attachment metadata
    wp_update_attachment_metadata( $attachment_id, $attachment_metadata );

    $ratio_value = $height / $width;`$image .= '<img class="wp-post-image croped-image ' . $custom_class . '" data-ratio="' . $ratio_value . '" width="' . $width . '" height="' . $height .'" src="' . $croped_image_url . '" alt="'. $alt_value .'">';
致命错误:无法在第591行的/home/liveep5/public_html/wp content/plugins/plugin/inc/tools.php中将字符串偏移量用作数组

$attachment_metadata['sizes']['croped-image-' . $width . '-' . $height] = array(
        'file'          => $pathinfo['basename'],
        'width'         => $width,
        'height'        => $height,
        'mime-type'     => get_post_mime_type($attachment_id)
    );
    // wp update attachment metadata
    wp_update_attachment_metadata( $attachment_id, $attachment_metadata );

    $ratio_value = $height / $width;`$image .= '<img class="wp-post-image croped-image ' . $custom_class . '" data-ratio="' . $ratio_value . '" width="' . $width . '" height="' . $height .'" src="' . $croped_image_url . '" alt="'. $alt_value .'">';
$attachment\u元数据['size']['croped-image-'.$width.-'.$height]=数组(
'文件'=>$pathinfo['basename'],
“宽度”=>$width,
“高度”=>$height,
“mime类型”=>get\u post\u mime\u类型($attachment\u id)
);
//wp更新附件元数据
wp_更新_附件_元数据($attachment_id,$attachment_metadata);
$ratio_值=$height/$width`$图像。='';
寻找其他问题,我知道我是noob,我需要更改代码。 请帮帮我


谢谢大家!

可能$attachment\u元数据不包含包含数组的键“size”。var_按照@magnus eriksson的建议转储它。

很可能$attachment_元数据不包含包含数组的键“size”。var\u按照@magnus eriksson的建议转储它。

转储变量:
var\u dump($attachment\u metadata)
并查看它实际包含的内容。591是哪一行?转储变量:
var\u Dump($attachment\u metadata)
并查看它实际包含的内容。591是哪一行?