PHP 소스 작성 중에 디버깅이 힘들기 때문에, 에러메시지 출력을 위해서 세팅 |
보통 개발중인 사이트에서는 상관이 없는데, 운영 중인 서버에서는 사용자가 보지 않도록 세팅을 하는 경우가 있음.
개발자 입장에서는 웹 서버 측에서 코드에 문제가 있으면 확인하고 싶은데 확인하기 쉽지 않으므로, 남용하지 않게 유의
[ 방법-1 ] php.ini 파일 수정
Error handling and logging 부분에서, error level 설정 부분은 다음과 같음
Error Level Constants:
; E_ALL - All errors and warnings (includes E_STRICT as of PHP 5.4.0)
; E_ERROR - fatal run-time errors
; E_RECOVERABLE_ERROR - almost fatal run-time errors
; E_WARNING - run-time warnings (non-fatal errors)
; E_PARSE - compile-time parse errors
; E_NOTICE - run-time notices (these are warnings which often result
; from a bug in your code, but it's possible that it was
; intentional (e.g., using an uninitialized variable and
; relying on the fact it is automatically initialized to an
; empty string)
; E_STRICT - run-time notices, enable to have PHP suggest changes
; to your code which will ensure the best interoperability
; and forward compatibility of your code
; E_CORE_ERROR - fatal errors that occur during PHP's initial startup
; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's
; initial startup
; E_COMPILE_ERROR - fatal compile-time errors
; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
; E_USER_ERROR - user-generated error message
; E_USER_WARNING - user-generated warning message
; E_USER_NOTICE - user-generated notice message
; E_DEPRECATED - warn about code that will not work in future versions
; of PHP
; E_USER_DEPRECATED - user-generated deprecation warnings
이 부분을 수정하면 됨
error_reporting = E_ALL
display_errors = On
[ 방법-2 ] php 소스에서 사용하기
<?php
error_reporting(E_ALL);
ini_set("display_errors", true);
?>
php 태그 상단에 선언해서 사용하면 됨
출력)
'LANGUAGE > PHP' 카테고리의 다른 글
[PHP] URL encode, decode / urlencode, urldecode, htmlentities ... (0) | 2020.03.11 |
---|---|
[PHP] number_format, 숫자 포맷 (0) | 2020.03.04 |
[PHP] timezone 설정 (0) | 2020.02.28 |
[PHP] 날짜함수(date, strtotime, mktime) (0) | 2020.02.28 |
[PHP] print_r(), 변수 정보 출력 (0) | 2020.02.27 |