/오류 로깅 (예 : /var/log/apache2/error.log
); 처리기는 false
을 반환해야합니다. 간략하게,
Is there a static way to throw exception in php
또는 : 다음은 "새로운 던져 ..."때문에, 문은 기본적으로 실행을 중단, 한 다음 "포장 기능에"트릭을 할 수있다, 또한 논의
function throwErrorException($errstr = null,$code = null, $errno = null, $errfile = null, $errline = null) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
function warning_handler($errno, $errstr, $errfile, $errline, array $errcontext) {
return false && throwErrorException($errstr, 0, $errno, $errfile, $errline);
# error_log("AAA"); # will never run after throw
/* Do execute PHP internal error handler */
# return false; # will never run after throw
}
...
set_error_handler('warning_handler', E_WARNING);
...
try {
mkdir($path, 0777, true);
} catch (Exception $e) {
echo $e->getMessage();
// ...
}
편집 : 더 정밀한 점검 후, 그것이 작동하지 않습니다 밝혀 다음 "return false && throwErrorException ...
"기본적으로 예외를 던지지, 그냥 오류 로그에 기록합니다; ""에서와 같이 "false &&
"부분을 제거하면 예외가 발생하지만 error_log에 로그인하지 않습니다 ...이 동작을 문서화하지 않았으므로 계속 게시합니다. 다른 곳에서.
http://stackoverflow.com/questions/136899/suppress-error-with-operator-in-php는 이와 같은 좋은 논의입니다. – Mez
아래 답변이 삭제 되었습니까? 소유자 또는 누군가에 의해? – user121196
참고 : http://stackoverflow.com/questions/1087365 – dreftymac