我如何消除这个错误?php中的非法字符串

我如何消除这个错误?php中的非法字符串,php,wordpress,Php,Wordpress,在更新一些wordpress插件后,我一直收到以下消息: 警告:第144行的…/public_html/wp content/themes/woodmart/inc/shortcodes/info-box.php中的非法字符串偏移量“target” 警告:第147行的…public_html/wp content/themes/woodmart/inc/shortcodes/info-box.php中的非法字符串偏移量“url” 我试图访问info-boh.php,下面是发生错误的代码: if

在更新一些wordpress插件后,我一直收到以下消息:

警告:第144行的…/public_html/wp content/themes/woodmart/inc/shortcodes/info-box.php中的非法字符串偏移量“target”

警告:第147行的…public_html/wp content/themes/woodmart/inc/shortcodes/info-box.php中的非法字符串偏移量“url”

我试图访问info-boh.php,下面是发生错误的代码:

if($attributes['target']=='\u blank'){
$onclick='window.open('esc_url($attributes['url'])。','u blank');
}否则{

$onclick='window.location.href=“'.esc_url($attributes['url'])。”;
您似乎得到的$attributes['url']为空。请将is_empty条件放在共享条件之前:

if(isset($attributes['url']) && !empty($attributes['url'])){
    if( $attributes['target'] == ' _blank' ) {
        $onclick = 'window.open("'. esc_url( $attributes['url'] ).'","_blank")';
    } else {
        $onclick = 'window.location.href="'. esc_url( $attributes['url'] ).'"';
    }
}

print\u r
/
var\u dump
查看var
$attributes
是否存在
['url']
['target']
意味着
$attributes
是一个字符串,您将其视为关联数组。您在哪里定义此变量?感谢您的帮助,但我不明白:-(什么是
$attributes
,您在哪里为该变量赋值?它是字符串,而不是数组。在您的代码中的某个地方,某些信息传递不正确。我建议您学习,因为我们无法仅基于此代码为您提供帮助。您需要找到问题的根源。