Error Handling

10 entries

assert Function Asserts an expectation that should always hold; failure throws AssertionError; only zend.assertions=1 executes it, while -1 (recommended for production) compiles it away at zero cost. error_clear_last Function Clears the record of the most recent error. error_get_last Function Returns the most recent error that occurred (type/message/file/line). error_log Function Log routing: message_type sends to system logger (0) / email (1) / destination file append (3) / SAPI log (4); type=0 always returns true. error_reporting Function Sets which error levels are reported and returns the current level. restore_error_handler Function Removes the current error handler and restores the previous one. set_error_handler Function Registers a custom callback to take over error handling. set_exception_handler Function Installs the fallback handler for uncaught throwables (both Error and Exception implement Throwable); returns the previously installed handler (null if none); the script ends after the callback returns. Structured Stream Errors Function The PHP 8.6 stream error family: the error_mode context option turns stream failures into thrown StreamExceptions or silence — errors become structured objects of StreamErrorCode enum + wrapperName + path, ending the era of the warning string. trigger_error Function Raises a user-level error or warning from user code.