【问题标题】:Fatal error: Cannot use string offset as an array on line 151致命错误:不能在第 151 行使用字符串偏移作为数组
【发布时间】:2013-11-28 06:59:18
【问题描述】:

我有这段代码,它运行良好,但我的一个客户得到了

致命错误:不能将字符串偏移量用作数组

我注释了产生错误的那一行。

                                <?php 

                                $thumbId1 = get_field('portfolio_images'); //this is the line that generates the error



                                $portfolio_large = $thumbId1[0]['image'];

                                $mafioso_smvideo = get_field('small_video',$post->ID);



                                if($mafioso_smvideo!='') {

                                    echo do_shortcode($mafioso_smvideo);

                                }

                                elseif (!$portfolio_large == ''){ 

                                ?>

                                        <?php

                                            echo '<img src="'.aq_resize( $portfolio_large, 340, 197, true ).'" alt="'.get_the_title().'" class="categ-thumb"/>';

                                        ?>

【问题讨论】:

标签: php arrays


【解决方案1】:
<?php

if(is_array($thumbId1)){

$portfolio_large = $thumbId1[0]['image'];

}

?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-21
    • 1970-01-01
    相关资源
    最近更新 更多