PHP选项与资讯函数库

error_log

(PHP3 , PHP4)

error_log ---  送出错误讯息到某处

语法 : int error_log (string message, int message_type [, string destination [, string extra_headers]])

说明 : 

送出一个错误讯息到web伺服器的错误记录,一个TCP埠号或是一个文件。第一个参数message是将要被记录的一个错误讯息内容,第二个参数message_type说明讯息要送往何处 :

error_log( )记录的型态 :

0 message送到PHP的系统记录者,使用作业系统的系统记录机制或是文件,取决于error_log的设定值。
1 以email的方式将message送到参数destination指定的地址,只有这个型态才会使用到extra_headers,此型态使用相同的内部函数mail( )。
2 message送到PHP除错连结,只有在远端的除错设为enable时,这个选项才有效。参数destination用来指定接收除错讯息的主机名称或是IP位址,埠号。
3 message附加在文件destination

Example :

<?php

   // Send notification through the server log if we can not

  // connect to the database.

  if (!Ora_Logon($username, $password)) {

       error_log("Oracle database not available!", 0);

  }

  // Notify administrator by email if we run out of FOO

  if (!($foo = allocate_new_foo()) {

        error_log ("Big trouble, we're all out of FOOs!", 1, "operator@mydomain.com");

  }

  // other ways of calling error_log():

  error_log ("You messed up!", 2, "127.0.0.1:7000");

  error_log ("You messed up!", 2, "loghost");

  error_log ("You messed up!", 3, "/var/tmp/my-errors.log");

?>     


上一页 首页 下一页