PHP has always been regarded as a language that cannot be used on the table, mainly because it relies heavily on various functions. But in fact, PHP is also the most widely used language in the website, which is related to its simplicity and convenience. Compared with other Website Languages, PHP does not have its own server and relies on servers such as Apache. If you use Tomcat, you will obviously feel that PHP is missing.
PHP has always been regarded as a language that cannot be used on the table, mainly because it relies heavily on various functions. But in fact, PHP is also the most widely used language in the website, which is related to its simplicity and convenience. Compared with other Website Languages, PHP does not have its own server and relies on servers such as Apache. If you use Tomcat, you will obviously feel that PHP is missing.
PHP has always been regarded as a language that cannot be used on the table, mainly because it relies heavily on various functions. But in fact, PHP is also the most widely used language in the website, which is related to its simplicity and convenience. Compared with other Website Languages, PHP does not have its own server and relies on servers such as Apache. If you use Tomcat, you will obviously feel that PHP has a background console missing, in the Tomcat console, you can see the log information output by the program. PHP lacks this capability. When you need to view logs in the background in real time when developing a PHP program, it is difficult to achieve your wish. A work und is to import logs to a file. PHP provideserror_log()To quickly output logs to a specified file.
The interface of this function is described as follows:
bool error_log ( string $message [, int $message_type = 0 [, string $destination [, string $extra_headers ]]] )
The first parameter is the log to be output, and the second parameter is the output mode. There are four methods, respectively:
Error_log ()Log Type
| 0 |
messageSystem log sent to PHP, use
The log mechanism or file of the operating system depends on
What is set by the error_log command.
This is a default option. |
| 1 |
messageSend to Parameterdestination
The email address.
Fourth Parameterextra_headersIt is used only in this type. |
| 2 |
It is no longer an option. |
| 3 |
messageSentdestination.
CharactermessageIt is not treated as a new row by default. |
| 4 |
messageIt is directly sent to the log processing program of SAPI. |
The most common one is output to a log file, which is 3.
The following is an example of usage: