duan7264 2015-04-27 10:20
浏览 84
已采纳

如何修复“警告非法字符串”?

I was working on another PHP version. But when i upload the site to client server due to Different PHP version i am getting these errors

Warning: Illegal string offset 'name' in /homepages/3/d227794433/htdocs/flyefg/wp-content/plugins/gameplan-shortcodes/shortcodes/testimonial.php on line 53

Warning: Illegal string offset 'position' in /homepages/3/d227794433/htdocs/flyefg/wp-content/plugins/gameplan-shortcodes/shortcodes/testimonial.php on line 53

Warning: Illegal string offset 'company' in /homepages/3/d227794433/htdocs/flyefg/wp-content/plugins/gameplan-shortcodes/shortcodes/testimonial.php on line 53

Warning: Illegal string offset 'name' in /homepages/3/d227794433/htdocs/flyefg/wp-content/plugins/gameplan-shortcodes/shortcodes/testimonial.php on line 53

Warning: Illegal string offset 'position' in /homepages/3/d227794433/htdocs/flyefg/wp-content/plugins/gameplan-shortcodes/shortcodes/testimonial.php on line 53

Warning: Illegal string offset 'company' in /homepages/3/d227794433/htdocs/flyefg/wp-content/plugins/gameplan-shortcodes/shortcodes/testimonial.php on line 53

Warning: Illegal string offset 'name' in /homepages/3/d227794433/htdocs/flyefg/wp-content/plugins/gameplan-shortcodes/shortcodes/testimonial.php on line 53

Warning: Illegal string offset 'position' in /homepages/3/d227794433/htdocs/flyefg/wp-content/plugins/gameplan-shortcodes/shortcodes/testimonial.php on line 53

Warning: Illegal string offset 'company' in /homepages/3/d227794433/htdocs/flyefg/wp-content/plugins/gameplan-shortcodes/shortcodes/testimonial.php on line 53

Code on Line 53 is

$output .= '<div class="name">'.$atts['name'].($atts['position']?', '.$atts['position']:'').($atts['company']?' - '.$atts['company']:'').'</div>';

Whole code is (Line 35-62)

function parse_testimonial_item($atts, $content, $id){
    $position = isset($atts['position']) ? $atts['position'] : '';
    $name = isset($atts['name']) ? $atts['name'] : '';
    $company = isset($atts['company']) ? $atts['company'] : '';
    wp_enqueue_script( 'jquery-isotope');
    global $testimonial_slides;

    $output = '';
    if($testimonial_slides > 1){
        if(function_exists( 'head_slide' )){
            $output .= head_slide($testimonial_slides, '', '', array('page'=>true));
        }
    }
    $output .= '<div class="testimonial style-1">';
    $output .= '<div class="tt-content icon-quote-right">';
    $output .= strip_tags($content);
    $output .= '<div class="tt-tooltip"><!----></div>';
    $output .= '</div>';
    $output .= '<div class="name">'.$atts['name'].($atts['position']?', '.$atts['position']:'').($atts['company']?' - '.$atts['company']:'').'</div>';
    $output .= '</div>';
    if($testimonial_slides > 1){
        if(function_exists( 'footer_slide' )){
            $output .= footer_slide(array('page'=>true));
        }
    }
    return $output;

}

Thank you

  • 写回答

3条回答 默认 最新

  • dongzhao1930 2015-04-27 10:25
    关注

    the array variable $atts does not contain 'name,position' etc thats why you are getting this error. check the data that is coming in the array $atts. Just replace $atts with @$atts problem solved.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用