Why the same method echo Realpath (Runtime_path); will produce different results?

Source: Internet
Author: User
Tags getmessage


In order to allow the custom error and exception handling mechanism to capture fatal errors, the thinkphp () method adds Trigger_error ($e [' message ') to the fatalerror () approach;

// 重新设置错误及异常处理机制 set_error_handler(array('\Think\ErrorLog','phplog')); set_exception_handler(array('\Think\ErrorLog','phplog'));
// 致命错误捕获static public function fatalError() {    Log::save();    if ($e = error_get_last()) {        switch($e['type']){          case E_ERROR:          case E_PARSE:          case E_CORE_ERROR:          case E_COMPILE_ERROR:          case E_USER_ERROR:            ob_end_clean();            // 抛出用户级别错误,让自定义的错误机制(phplog)能够捕获            trigger_error($e['message']); //自己添加的            self::halt($e);            break;        }    }}

Here's your own error mechanism.

    public static function Phplog ($errno, $errstr = null, $errfile = NULL, $errline = null) {if ($errstr = = = null) { Exception $backtrace = arr                    Ay (' logtype ' = ' exception ', ' environment ' = = Array (                    ' Code ' = $errno->getcode (),//exception code ' Message ' = $errno->getmessage (),//exception                                                              Message ' file ' = $errno->getfile (),                                                              Exception file ' line ' = $errno->getline (),                                                             Exception line ' debugbacktrace ' = $errno->gettrace () anomaly tracking));            } else if (error_reporting ()) {//General error $backtrace = Array (' LogType ' = ' error ', ' environment ' = + AR                    Ray (' Code ' = $errno, ' message ' = $errstr, ' File ' = $errfile, ' line ' = ' $errline, ' debugbacktrace            ' = = Debug_backtrace ()//Error backtracking)        );            } else {//"@" error        return;                       } $index = Iconv (' UTF-8 ', ' utf-8//ignore ', $index = & $backtrace [' Environment '] [' message ']);                 Remove invalid characters self::formatlog ($backtrace);                                                                   Format Log $errorLevel = Array (                   Output log information 0 = ' Exception ', Exception 1 = ' E_error ',//Fatal run-time error. The error cannot be recovered.            Execution of the script was interrupted. 2 = ' e_warning ',//non-fatal run-time error.            The execution of the script is not interrupted. 4 = ' e_parse ',//compile-time parsing error.            Parsing errors should only be generated by the parser. 8 = ' e_notice ',//run-time prompt.            May be an error, or it may occur when the script is running normally.            "E_core_error",//errors generated internally by PHP.            "E_core_warning",//warnings generated internally by PHP.            "E_compile_error",//errors generated internally by the Zend scripting engine.            "E_compile_warning",//warnings generated internally by the Zend scripting engine.            The run-time error generated by the call to the Trigger_error () function is ' e_user_error '. "E_user_w"Arning ',//due to a run-time warning generated by calling the Trigger_error () function.            1024x768 = ' e_user_notice ',//run-time prompt generated by calling the Trigger_error () function. 2048 = ' e_strict ',//runtime prompt.            Benefit from enhanced code interoperability and compatibility.            4096 = ' e_recoverable_error ',//fatal error that can be captured. 8192 = ' e_deprecated ',//runtime notification.            When enabled, warns you about code that might not work correctly in a future release.            16384 = ' e_user_deprecated ',//user-produced less warning message.        30719 = ' E_all ',//all errors and warnings except E_strict.        );        $temp = Htmlentities ($index, ent_quotes, ' UTF-8 '); Self::writelog ($backtrace, ' php ', ' {$errorLevel [$backtrace [' Environment '] [' Code ']}: \ "
{$temp} 
\ "in {$backtrace [' environment '] [' file ']} on line {$backtrace [' environment '] [' line ']}. Timestamp: {$_server[' request_time '} "); }protected static function Writelog (& $logData, $logType, $printStr) {self:: $lastError [' error '] = & $logData ; if (app_debug) {//debug mode Echo $printStr; Print log} $logPath = Runtime_path. ' Errorlog '. Date ('/y/m/d ', $_server[' request_time '). $logType; echo Realpath (Runtime_path); Result 1. D:\wamp\www\XMQZ\Runtime Results 2. D:\wamp\Apache24\Runtime Is_dir ($temp = dirname ($logPath)) | | mkdir ($temp, 0777, true); @file_put_contents ($logPath, Strtr (Serialize ($logData), array ("\ r \ n" = ". ($temp = chr (0)), "\ r" = $temp, "\ n" = $temp)). "\ n", File_append | Lock_ex ); }

Reply content:


In order to allow the custom error and exception handling mechanism to capture fatal errors, the thinkphp () method adds Trigger_error ($e [' message ') to the fatalerror () approach;

// 重新设置错误及异常处理机制 set_error_handler(array('\Think\ErrorLog','phplog')); set_exception_handler(array('\Think\ErrorLog','phplog'));
// 致命错误捕获static public function fatalError() {    Log::save();    if ($e = error_get_last()) {        switch($e['type']){          case E_ERROR:          case E_PARSE:          case E_CORE_ERROR:          case E_COMPILE_ERROR:          case E_USER_ERROR:            ob_end_clean();            // 抛出用户级别错误,让自定义的错误机制(phplog)能够捕获            trigger_error($e['message']); //自己添加的            self::halt($e);            break;        }    }}

Here's your own error mechanism.

    public static function Phplog ($errno, $errstr = null, $errfile = NULL, $errline = null) {if ($errstr = = = null) { Exception $backtrace = arr                    Ay (' logtype ' = ' exception ', ' environment ' = = Array (                    ' Code ' = $errno->getcode (),//exception code ' Message ' = $errno->getmessage (),//exception                                                              Message ' file ' = $errno->getfile (),                                                              Exception file ' line ' = $errno->getline (),                                                             Exception line ' debugbacktrace ' = $errno->gettrace () anomaly tracking));            } else if (error_reporting ()) {//General error $backtrace = Array (' LogType ' = ' error ', ' environment ' = + AR                    Ray (' Code ' = $errno, ' message ' = $errstr, ' File ' = $errfile, ' line ' = ' $errline, ' debugbacktrace            ' = = Debug_backtrace ()//Error backtracking)        );            } else {//"@" error        return;                       } $index = Iconv (' UTF-8 ', ' utf-8//ignore ', $index = & $backtrace [' Environment '] [' message ']);                 Remove invalid characters self::formatlog ($backtrace);                                                                   Format Log $errorLevel = Array (                   Output log information 0 = ' Exception ', Exception 1 = ' E_error ',//Fatal run-time error. The error cannot be recovered.            Execution of the script was interrupted. 2 = ' e_warning ',//non-fatal run-time error.            The execution of the script is not interrupted. 4 = ' e_parse ',//compile-time parsing error.            Parsing errors should only be generated by the parser. 8 = ' e_notice ',//run-time prompt.            May be an error, or it may occur when the script is running normally.            "E_core_error",//errors generated internally by PHP.            "E_core_warning",//warnings generated internally by PHP.            "E_compile_error",//errors generated internally by the Zend scripting engine.            "E_compile_warning",//warnings generated internally by the Zend scripting engine.            The run-time error generated by the call to the Trigger_error () function is ' e_user_error '. "E_user_w"Arning ',//due to a run-time warning generated by calling the Trigger_error () function.            1024x768 = ' e_user_notice ',//run-time prompt generated by calling the Trigger_error () function. 2048 = ' e_strict ',//runtime prompt.            Benefit from enhanced code interoperability and compatibility.            4096 = ' e_recoverable_error ',//fatal error that can be captured. 8192 = ' e_deprecated ',//runtime notification.            When enabled, warns you about code that might not work correctly in a future release.            16384 = ' e_user_deprecated ',//user-produced less warning message.        30719 = ' E_all ',//all errors and warnings except E_strict.        );        $temp = Htmlentities ($index, ent_quotes, ' UTF-8 '); Self::writelog ($backtrace, ' php ', ' {$errorLevel [$backtrace [' Environment '] [' Code ']}: \ "
{$temp} 
\ "in {$backtrace [' environment '] [' file ']} on line {$backtrace [' environment '] [' line ']}. Timestamp: {$_server[' request_time '} "); }protected static function Writelog (& $logData, $logType, $printStr) {self:: $lastError [' error '] = & $logData ; if (app_debug) {//debug mode Echo $printStr; Print log} $logPath = Runtime_path. ' Errorlog '. Date ('/y/m/d ', $_server[' request_time '). $logType; echo Realpath (Runtime_path); Result 1. D:\wamp\www\XMQZ\Runtime Results 2. D:\wamp\Apache24\Runtime Is_dir ($temp = dirname ($logPath)) | | mkdir ($temp, 0777, true); @file_put_contents ($logPath, Strtr (Serialize ($logData), array ("\ r \ n" = ". ($temp = chr (0)), "\ r" = $temp, "\ n" = $temp)). "\ n", File_append | Lock_ex ); }
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.