Home > Backend Development > PHP Tutorial > error_log() function in PHP

error_log() function in PHP

王林
Release: 2023-09-13 19:58:01
forward
1636 people have browsed it

error_log() function in PHP

The error_log() function sends errors to the server error log, a file, or a remote destination.

grammar

error_log(message, message_type, destination, extra_headers)
Copy after login

parameter

  • 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().

return

The error_log() function returns TRUE on success and FALSE on failure.

Example

The following is an example -

Live Demo

<?php
   error_log("That’s no good!", 3, "/var/tmp/my-errors.log");
?>
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template