<?php
If you cannot connect to the database, send a notification to the server log
if (!Ora_logon($username,$password)) {
Error_log("Oracle Database Not available!",0);
}
Notify the administrator by email if FOO is exhausted
if (! ($foo=Allocate_new_foo())) {
Error_log("Big trouble, we ' re all out of foos!" , 1,
"[email protected]");
}
Another way to call Error_log ():
Error_log("You messed up!" , 3, "/var/tmp/my-errors.log");
?>
Error_log () is a function that sends an error message to a place, which is more common in programming, especially during the debugging phase of a program.
bool error_log ( string $message [, int $message _type = 0 [, string $destination [, string $extra _headers]] )
Send the error message to the Web server's error log, or to a file.
-
-
message
-
-
The error message that should be logged.信息长度限制:The default seem to be 1024 but can be changed by adjusting the value of the runtime configuration value of ‘log_errors_max_len‘
-
-
message_type
-
Set where the error should be sent. There are several possible types of information:
error_log () log type
0 |
message The system log sent to PHP, using the operating system's logging mechanism or a file, depends on what the error_log Directive sets. This is a default option. |
1 |
message destination the e-mail address to send to the parameter settings. The fourth parameter extra_headers is only used in this type. |
2 |
is no longer an option. |
3 |
message is sent to a destination file in the location. Characters message are not treated by default as a new line. |
4 |
message Sent directly to the SAPI log handler. |
-
-
destination
-
-
Goal. Its meaning is described above, as determined by the message_type
parameters.
-
-
extra_headers
-
-
Extra head. message_type
used when set to 1 . This information type uses the same built-in function for mail ().
Error_log () example