본문 바로가기

개발이야기/PHP

Error, Warning 안나오게 하기 (에러, 경고)

728x90

Error, Warning 안나오게 하기 (에러, 경고)








1
2
3
4
5
<?
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
?>
cs


에러가 나오는 경우 코드 가장 윗쪽에 위의 코드를 추가 해도 되고, 오류가 나는 구문 앞에 @(골뱅이) 를 붙여도 에러가 무시 된다


추가 적인 내용은


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?
// Turn off all error reporting
error_reporting(0);
 
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
 
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
 
// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);
 
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
 
// Report all PHP errors
error_reporting(-1);
 
// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
?>
cs


를 참고 해주고, 공식문서는 http://php.net/manual/en/function.error-reporting.php