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'];
전체 2,427 |RSS
그누보드5 팁자료실 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT