You can disable the display of error messages by suppressing error messages globally (in configuration or runtime) with the display_errors parameter, or in each case by prefixing the function call with @ -character. (For example, @mkdir('...') ).
Then you can check error_get_last when mkdir returns false .
The global rules apply to error logging. You can log errors manually using error_log .
See the Error Handling section of the manual for further reference.
Edit:
As pointed out in the comments, a custom error handler is also possible, possibly more reliable (depending on your implementation), but, of course, a more elegant solution.
function err_handler($errno, $errstr) {
Thus, the error message will not be displayed unless you explicitly pronounce it. However, note that when using a custom error handler, error_get_last will return NULL .
source share