테스트 사이트 - 개발 중인 베타 버전입니다

PHP8.x 에서 "Warning: Undefined array key ..." 를 만나면

· 3년 전 · 10707 · 17

Warning: Undefined array key "bo_mobile_subject" in .../lib/new_latest.lib.php on line 139

 

139: $list[$i]['bo_subject'] = ((G5_IS_MOBILE && $row['bo_mobile_subject']) ? $row['bo_mobile_subject'] : $row['bo_subject']);


=>  정의되지 않은 array key 변수 앞에 @ 를 붙이면 Warning 을 막을 수 있습니다.

$list[$i]['bo_subject'] = ((G5_IS_MOBILE && @$row['bo_mobile_subject']) ? @$row['bo_mobile_subject'] : @$row['bo_subject']);

 

참고 : https://www.php.net/manual/en/language.operators.errorcontrol.php

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 17개

유익한 정보입니다. 감사합니다.
3년 전
@arari 감사합니다 ^^
@를 붙여서 에러를 건너띄는건 올바른 방법이 아닙니다.
더군다나 8.0부터는 해당기능이 Deprecate 상태이기때문에 나중버전에서는 삭제될수도 있습니다.
Warning

Prior to PHP 8.0.0, the value of the severity passed to the custom error handler was always 0 if the diagnostic was suppressed. This is no longer the case as of PHP 8.0.0.
3년 전
@나리스 감사합니다 ^^
순정 G5 에서 없던 Warning 이 갑자기 생겨서 해결책으로 찾은건데 다른 좋은 방법이 있으면 알려주세요~
감사합니다
3년 전
@욱이요 감사합니다 ^^
$list[$i]['bo_subject'] = (G5_IS_MOBILE && !empty($row['bo_mobile_subject'])) ? $row['bo_mobile_subject'] : $row['bo_subject'];
감사합니다
3년 전
@라콩이 감사합니다 ^^
isset($row['bo_mobile_subject']) && $row['bo_mobile_subject']

게시글 목록

번호 제목
24318
24317
24315
24309
24294
24293
24277
24262
24260
24253
24251
24236
24233
24228
24226
24221
24214
24203
24201
24199
24196
24195
24194
24192
24191
24187
24185
24183
24172
24168