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

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


==PHP 소스코드 내에서 On하기==
==PHP 소스코드 내에서 On하기==
<source lang='php'>
<syntaxhighlight lang='php'>
ini_set("display_errors", 1);  
ini_set("display_errors", 1);  
</source>
</syntaxhighlight>


==예시 1: On 상태==
==예시 1: On 상태==
<source lang='cli'>
<syntaxhighlight lang='console'>
[root@zeta1 ~]# cat /etc/php.ini | grep ^display
[root@zeta1 ~]# cat /etc/php.ini | grep ^display
display_errors = On
display_errors = On
display_startup_errors = On
display_startup_errors = On
</source>
</syntaxhighlight>
<source lang='cli'>
<syntaxhighlight lang='console'>
[root@zeta1 ~]# php -i | grep display
[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: Off 상태==
==예시 2: Off 상태==
<source lang='cli'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# cat /etc/php.ini | grep ^display
[root@zetawiki ~]# cat /etc/php.ini | grep ^display
display_errors = Off
display_errors = Off
display_startup_errors = Off
display_startup_errors = Off
</source>
</syntaxhighlight>
<source lang='cli'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# php -i | grep display
[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>


==같이 보기==
==같이 보기==
62번째 줄: 62번째 줄:
*[[php -i]]
*[[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 }}