채택완료

Trying to access array offset on value of type bool 에러 관련

Copy
<?php
                        if ($list[$i]['is_notice']) { // 공지사항  ?>
                            <span class="is_notice" style="<?php echo $line_height_style; ?>">공지</span>
                        <?php } else {
                            $thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true);

                            if($thumb['src']) {
                                $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" >';
                            } else {
                                $img_content = '<span class="no_image" style="'.$line_height_style.'">no image</span>';
                            }

                            echo run_replace('thumb_image_tag', $img_content, $thumb);
                        }
                         ?>

 

위에 코드 작성 시

Copy
if($thumb['src']) {
해당 부분에서 Trying to access array offset on value of type bool 에러 발생하고 있습니다

 

php 버전은 8.2.4 입니다

 

조언 부탁드립니다

|

답변 1개

채택된 답변
+20 포인트

Copy
<?php
if ($list[$i]['is_notice']) { // 공지사항  ?>
    <span class="is_notice" style="<?php echo $line_height_style; ?>">공지</span>
<?php } else {
    $thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true);
    if(is_array($thumb) && isset($thumb['src'])) {
        $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" >';
    } else {
        $img_content = '<span class="no_image" style="'.$line_height_style.'">no image</span>';
    }
    echo run_replace('thumb_image_tag', $img_content, $thumb);
}
?>

 

요렇게 수정해보세요

답변을 작성하려면 로그인이 필요합니다.