"PHP display errors"의 두 판 사이의 차이

 
(사용자 2명의 중간 판 13개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
;PHP display_errors
;PHP display_errors
;PHP 오류 표시 설정
;PHP 오류 표시 설정
* PHP 오류를 표준출력([[STDOUT]])으로 출력할 것인지에 관한 PHP 설정
*  On일 경우, 아파치의 표준출력은 웹페이지으므로 사용자의 웹브라우저에 표시된다.
* CLI에서는 본 설정과 상관없이(즉 Off일 경우에도) 오류가 출력된다.
:On일 경우에는 오류 메시지가 2번 출력된다.


==예시 1: 오류 표시==
==PHP 소스코드 내에서 On하기==
<source lang='cli'>
<syntaxhighlight lang='php'>
[root@zeta1 ~]# php -i | grep -i display
ini_set("display_errors", 1);
</syntaxhighlight>
 
==예시 1: On 상태==
<syntaxhighlight lang='console'>
[root@zeta1 ~]# cat /etc/php.ini | grep ^display
display_errors = On
display_startup_errors = On
</syntaxhighlight>
<syntaxhighlight lang='console'>
[root@zeta1 ~]# php -i | grep display
display_errors => STDOUT => STDOUT
display_errors => STDOUT => STDOUT
display_startup_errors => On => On
display_startup_errors => On => On
</source>
</syntaxhighlight>
<source lang='cli'>
 
;오류 테스트
<syntaxhighlight lang='console'>
[root@zeta1 ~]# php -r "asdf();"
[root@zeta1 ~]# php -r "asdf();"
PHP Fatal error:  Call to undefined function asdf() in Command line code on line 1
PHP Fatal error:  Call to undefined function asdf() in Command line code on line 1


Fatal error: Call to undefined function asdf() in Command line code on line 1
Fatal error: Call to undefined function asdf() in Command line code on line 1
</source>
</syntaxhighlight>


==예시 2: 오류 숨김==
==예시 2: Off 상태==
<source lang='cli'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# php -i | grep -i display
[root@zetawiki ~]# cat /etc/php.ini | grep ^display
display_errors = Off
display_startup_errors = Off
</syntaxhighlight>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# php -i | grep display
display_errors => Off => Off
display_errors => Off => Off
display_startup_errors => Off => Off
display_startup_errors => Off => Off
</source>
</syntaxhighlight>
<source lang='cli'>
 
;오류 테스트
<syntaxhighlight lang='console'>
[root@zetawiki ~]# php -r "asdf();"
[root@zetawiki ~]# php -r "asdf();"
PHP Fatal error:  Call to undefined function asdf() in Command line code on line 1
PHP Fatal error:  Call to undefined function asdf() in Command line code on line 1
</source>
</syntaxhighlight>
<source lang='cli'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# php -r "ini_set('display_errors',1); asdf();"
[root@zetawiki ~]# php -r "ini_set('display_errors',1); asdf();"
PHP Fatal error:  Call to undefined function asdf() in Command line code on line 1
PHP Fatal error:  Call to undefined function asdf() in Command line code on line 1


Fatal error: Call to undefined function asdf() in Command line code on line 1
Fatal error: Call to undefined function asdf() in Command line code on line 1
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[PHP 에러메시지 보이게 하기]]
*[[아파치 PHP 에러메시지 보이게 하기]]
*[[/var/log/httpd/error_log]]
*[[PHP ini_set()]]
*[[PHP ini_set()]]
*[[php -i]]


==참고 자료==
==참고==
*http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display
*http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display
*http://php.net/manual/en/errorfunc.configuration.php
*http://php.net/manual/en/errorfunc.configuration.php


[[분류: PHP 오류]]
[[분류: PHP 오류]]

2023년 1월 19일 (목) 16:06 기준 최신판

1 개요[ | ]

PHP display_errors
PHP 오류 표시 설정
  • PHP 오류를 표준출력(STDOUT)으로 출력할 것인지에 관한 PHP 설정
  • On일 경우, 아파치의 표준출력은 웹페이지으므로 사용자의 웹브라우저에 표시된다.
  • CLI에서는 본 설정과 상관없이(즉 Off일 경우에도) 오류가 출력된다.
On일 경우에는 오류 메시지가 2번 출력된다.

2 PHP 소스코드 내에서 On하기[ | ]

ini_set("display_errors", 1);

3 예시 1: On 상태[ | ]

[root@zeta1 ~]# cat /etc/php.ini | grep ^display
display_errors = On
display_startup_errors = On
[root@zeta1 ~]# php -i | grep display
display_errors => STDOUT => STDOUT
display_startup_errors => On => On
오류 테스트
[root@zeta1 ~]# php -r "asdf();"
PHP Fatal error:  Call to undefined function asdf() in Command line code on line 1

Fatal error: Call to undefined function asdf() in Command line code on line 1

4 예시 2: Off 상태[ | ]

[root@zetawiki ~]# cat /etc/php.ini | grep ^display
display_errors = Off
display_startup_errors = Off
[root@zetawiki ~]# php -i | grep display
display_errors => Off => Off
display_startup_errors => Off => Off
오류 테스트
[root@zetawiki ~]# php -r "asdf();"
PHP Fatal error:  Call to undefined function asdf() in Command line code on line 1
[root@zetawiki ~]# php -r "ini_set('display_errors',1); asdf();"
PHP Fatal error:  Call to undefined function asdf() in Command line code on line 1

Fatal error: Call to undefined function asdf() in Command line code on line 1

5 같이 보기[ | ]

6 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}