Error Control Operators ¶
PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.
If you have set a custom error handler function with set_error_handler() then it will still get called, but this custom error handler can (and should) call error_reporting() which will return 0 when the call that triggered the error was preceded by an @.
If the track_errors feature is enabled, any error message generated by the expression will be saved in the variable $php_errormsg. This variable will be overwritten on each error, so check early if you want to use it.
<?php
/* Intentional file error */
$my_file = @file ('non_existent_file') or
die ("Failed opening file: error was '$php_errormsg'");
// this works for any expression, not just functions:
$value = @$cache[$key];
// will not issue a notice if the index $key doesn't exist.
?>
See also error_reporting() and the manual section for Error Handling and Logging functions.
source - http://php.net/manual/en/language.operators.errorcontrol.php
You also can use the @ operator to mute errors occurring in the constructor, e.g. @new.
source - http://php.net/manual/kr/oop4.constructor.php
'Development > PHP' 카테고리의 다른 글
php - stdClass (0) | 2015.06.10 |
---|---|
php - eclipse debugging (0) | 2015.06.04 |
php - eclipse zend debugger plugin install (0) | 2015.06.03 |
php - array (0) | 2013.06.19 |
php - foreach 문 (0) | 2013.06.19 |