댓글 검색 목록

[php] 편리한 배열 관련 루틴 및 더 나은 유형 캐스팅

페이지 정보

작성자 운영자 작성일 20-08-02 09:39 조회 755 댓글 0

PHP 프로젝트에서 몇 가지 문제에 직면합니다 

  • Illogical type casting (PHP's native implementation is way too "smart")
  • Pointless casts like array => float are allowed
  • Boilerplate code to work with arrays (check if isset(), throw an exception, cast the type, etc.)

예.

$userId = $queryParams['userId'] ?? null;
if ($userId === null) {
    throw new BadRequestException();
}
$userId = (int)$userId;


https://github.com/zakirullin/mess 



댓글목록 0

등록된 댓글이 없습니다.

웹학교 로고

온라인 코딩학교

코리아뉴스 2001 - , All right reserved.