-
상수
define('NAME', 'Value');
define 함수를 사용해서 상수를 선언할 경우 한번 값이 설정되면 변경할 수 없다.
그리고 PHP 페이지 전역에서 접근할 수 있다.
옵셔널로 불리언은 상수명이 대소문자를 구분하는지 여부를 나타낸다 (구분하면 true , 아니라면 false)
-> 상수는 사이트가 동작하는데 필요한 정보를 저장하기 위해 자주 사용되지만, 상수의 값은 사이트가 설치될 때만 값이 변경된다 (사이트가 새로운 서버로 처음 옮겨질 때, 동일한 코드가 다른 웹사이트에서 사용될 때)
const NAME = 'Value';
위의 방식으로 선언하면 클래스 내부에 상수를 정의하는데 사용할 수 있다 (define은 불가능)
'php' 카테고리의 다른 글
배열 확인 함수 (0) 2023.10.30 class 에서 자기 자신을 instance하기 (0) 2023.10.19 php 배열 함수 (0) 2023.09.13 정규 표현식 (0) 2023.09.13 CI 프레임워크 활용 (주가스크래퍼) (0) 2023.09.12