The error_log function is widely used in PHP to send error messages to the web server.
The syntax is:
error_log(message, type, destination, headers)
message
is the user-defined error message.type
specifies where the error should go. destination
specified. This parameter also makes use of headers
to add additional information.
destination
specifies the addressee or the file name depending on the type
.headers
specify the from, cc, bcc if the type
is set to .Only message
is required, the rest are optional fields.
The function returns true or false depending upon the success or failure of the log.
Remember: It is not binary safe and; therefore, a null character will truncate the message.
The following code gives an example of how failed login attempts can be logged in a file:
<?php// Notify the system of multiple invalid login attemptserror_log("Multiple failed attempts for user", 3, "/var/tmp/system_errors.log");?>
This function can be used to send emails to other users, use default settings, or send the error logs to the SAPI logging handler depending upon the type selected by the user.
Free Resources