PHP8.x 에서 "Warning: Undefined array key ..." 를 만나면 > 그누보드5 팁자료실

그누보드5 팁자료실

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

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

본문

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

추천
5
  • 복사

댓글 16개

@를 붙여서 에러를 건너띄는건 올바른 방법이 아닙니다.
더군다나 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.
감사합니다 ^^
순정 G5 에서 없던 Warning 이 갑자기 생겨서 해결책으로 찾은건데 다른 좋은 방법이 있으면 알려주세요~

신고가 접수된 글입니다.
신고 횟수가 1회 이상이면 글을 확인하지 못합니다.

$list[$i]['bo_subject'] = (G5_IS_MOBILE && !empty($row['bo_mobile_subject'])) ? $row['bo_mobile_subject'] : $row['bo_subject'];
© SIRSOFT
현재 페이지 제일 처음으로