PHP는 @(at 표시)이라는 한 개의 오류 제어 연산자를 제공한다. PHP의 표현식 앞에 이 표시가 붙으면, 해당 표현식에서 발생한 모든 에러 메시지가 무시된다.
만약 track_errors 기능이 활성화 되어 있다면, 해당 표현식에서 발생한 모든 에러 메시지는 $php_errormsg 라는 전역 변수에 저장될 것이다. 이 변수의 값은 매번 에러가 발생할 때마다 새로 설정된다. 따라서 만약 여러분이 이 변수를 사용하려면 에러가 발생한 직후에 최대한 빨리 사용하여야 한다.
<?php /* Intentional SQL error (extra quote): */ $res = @mysql_query ("select name, code from 'namelist") or die ("Query failed: error was '$php_errormsg'"); ?> |
See also error_reporting().
주의 |
Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why. |