Prev | Current Page 112 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

GetBacktrace
- ErrorHandler.Handler */
$backtrace = ErrorHandler::GetBacktrace(2);
// Error message to be displayed, logged, or mailed
$error_message = "\nERRNO: $errNo\nTEXT: $errStr" .
"\nLOCATION: $errFile, line " .
"$errLine, at " . date('F j, Y, g:i a') .
"\nShowing backtrace:\n$backtrace\n\n";
// Email the error details, in case SEND_ERROR_MAIL is true
if (SEND_ERROR_MAIL == true)
error_log($error_message, 1, ADMIN_ERROR_MAIL, "From: " .
SENDMAIL_FROM . "\r\nTo: " . ADMIN_ERROR_MAIL);
// Log the error, in case LOG_ERRORS is true
if (LOG_ERRORS == true)
error_log($error_message, 3, LOG_ERRORS_FILE);
/* Warnings don't abort execution if IS_WARNING_FATAL is false
E_NOTICE and E_USER_NOTICE errors don't abort execution */
if (($errNo == E_WARNING && IS_WARNING_FATAL == false) ||
($errNo == E_NOTICE || $errNo == E_USER_NOTICE))
// If the error is nonfatal ...
{
// Show message only if DEBUGGING is true
if (DEBUGGING == true)
echo '
' . $error_message . '
';
}
else
// If error is fatal ...
{
// Show error message
if (DEBUGGING == true)
echo '
'. $error_message . '
';
else
echo SITE_GENERIC_ERROR_MESSAGE;
CHAPTER 3 ?–  STARTING THE TSHIRTSHOP PROJECT 53
// Stop processing the request
exit();
}
}
// Builds backtrace message
public static function GetBacktrace($irrelevantFirstEntries)
{
$s = '';
$MAXSTRLEN = 64;
$trace_array = debug_backtrace();
for ($i = 0; $i < $irrelevantFirstEntries; $i++)
array_shift($trace_array);
$tabs = sizeof($trace_array) - 1;
foreach ($trace_array as $arr)
{
$tabs -= 1;
if (isset ($arr['class']))
$s .


Pages:
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124