The error_log() function sends errors to the server error log, a file, or a remote destination.
error_log(message, message_type, destination, extra_headers)
message - The error message that should be logged.
message_type - It says where the error should occur. Possible message types are as follows
0 - Default. Errors are sent to the server logging system or to a file, depending on how the error_log configuration is set in the php.ini file
1 - Errors are emailed to the address in the target parameter. This message type is the only one that uses the headers parameter
2 - Errors are sent through the PHP debug connection. This option is only available in PHP 3
3 - Errors are added to the file target string
destination - Depends on the message_type parameter as described above.
extra_headers - When the message_type parameter is set to 1, extra headers are used. This message type uses the same internal function as mail().
The error_log() function returns TRUE on success and FALSE on failure.
The following is an example -
Live Demo
<?php error_log("That’s no good!", 3, "/var/tmp/my-errors.log"); ?>
The text will be saved in the log.
The above is the detailed content of error_log() function in PHP. For more information, please follow other related articles on the PHP Chinese website!