-
엄격한 타입 활성화php 2023. 9. 4. 08:50
1. 엄격한 타입 활성화
-> PHP 인터프리터는 string '1'을 int 1로 변환하거나
boolen true를 int 1로 변환하는 등 타입의 변환이 자유로운 편이다.
하지만 이런 타입의 변환을 막으려면 다음과 같이 php 구문의 상단에 선언할 수 있다
<?php declare(strict_types = 1);
위의 구문은 함수가 호출되는 페이지에서 활성화 해야한다.
'php' 카테고리의 다른 글
Class (0) 2023.09.06 지정인수 (0) 2023.09.06 전역 / 정적 / 옵셔널 변수 (0) 2023.09.04 워드프레스 페이지 추가 (0) 2023.09.01 php 파일 예약 실행 (0) 2023.08.30