dongshuo2752 2014-03-16 11:58
浏览 48

我有两个PHP代码,它给了我错误:

Warning: Illegal string offset 'hide_classes' in /home/creativi/public_html/wp-content/plugins/authpro/content-builder/models/layouts.php on line 131

This is the code that the warning is relating to:

 // mimick widgets mechanism
        $instance = empty($layoutInformation['layoutData']) ? array() : $layoutInformation['layoutData'];

        global $thisWidgetInstanceData;
        $thisWidgetInstanceData = $instance;

        //Get layout styles
        $styles = $this->generateLayoutStyles($instance);
        $styles['hide_classes'] = null; //override hide class in admin editor
        // var_dump($instance);
        ?>

second one :

Warning: Illegal string offset 'show_delay_attribute' in /home/creativi/public_html/wp-content/plugins/authpro/content-builder/models/layouts.php on line 207 >

related to :

 <div class="row-fluid<?php echo $styles['custom_classes'] ?><?php echo $styles['shadow_class'] ?><?php echo $styles['hide_classes'] ?><?php echo $styles['bg_effect_class'] ?>" id="layout-<?php echo $layoutNumber; ?>" style="<?php echo $styles['layout_style']; ?>" <?php echo $styles['show_delay_attribute']; ?>>

Any help would be greatly appreciated.

  • 写回答

1条回答 默认 最新

  • douji6667 2014-03-16 12:43
    关注

    Sounds like $styles is a string and you are trying to access it as an array using another string, which won't work.

    As suggested var_dump $styles or inspect in a debugger to get an idea of what is happening.

    In general, you should check for an array key exists before doing this sort of thing, usually

    echo $array['key'] ? $array['key'] : ''; for echo statements will produce an empty string rather than an error.

    I think the problem is in $this->generateLayoutStyles not returning what you expect.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题