當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Spoon::getExceptionCallback方法代碼示例

本文整理匯總了PHP中Spoon::getExceptionCallback方法的典型用法代碼示例。如果您正苦於以下問題:PHP Spoon::getExceptionCallback方法的具體用法?PHP Spoon::getExceptionCallback怎麽用?PHP Spoon::getExceptionCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Spoon的用法示例。


在下文中一共展示了Spoon::getExceptionCallback方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: exceptionHandler


//.........這裏部分代碼省略.........
											</td>
										</tr>';
        }
    } else {
        $output .= '				<tr>
											<td style="vertical-align: top; font-family: Verdana, Tahoma, Arial; font-size: 10px; color: #000000;">No trace available.</td>
										</tr>';
    }
    // output the superglobal variables, if any
    $hasVars = false;
    foreach (array('GET', 'POST', 'COOKIE', 'FILES') as $superGlobal) {
        $hasVars |= count($GLOBALS['_' . $superGlobal]);
    }
    if ($hasVars) {
        $output .= '				</table>
									</td>
								<tr>
								<tr>
									<td style="vertical-align: top; font-family: Verdana, Tahoma, Arial; font-size: 10px; color: #000000;">&nbsp;</td>
								</tr>
								<!-- variables -->
								<tr>
									<td style="background-color: #EEEEEE; border: 1px solid #B2B2B2;">
										<h1 style="font-size: 12px; margin: 5px 5px 12px 5px; padding: 0 0 5px 0; color: #000000; font-family: Verdana, Tahoma, Arial; border-bottom: 1px solid #999999;">' . $name . ' &raquo; Variables</h1>
										<table width="550px;">' . "\n";
        foreach (array('GET', 'POST', 'COOKIE', 'FILES') as $superGlobal) {
            if (!empty($GLOBALS['_' . $superGlobal])) {
                $output .= '				<tr>
													<th width="110px" style="vertical-align: top; text-align: left; font-weight: 700; padding: 0 10px 0 10px; font-family: Verdana, Tahoma, Arial; font-size: 10px; color: #000000;">$_' . $superGlobal . '</th>
													<td style="vertical-align: top; font-family: Verdana, Tahoma, Arial; font-size: 10px; color: #000000;">
														<pre style="font-family: Courier; margin-bottom: 10px;">' . exceptionHandlerDumper($GLOBALS['_' . $superGlobal]) . '</pre>
													</td>
												</tr>' . "\n";
            }
        }
    }
    // continue output generation
    $output .= '				</table>
								</td>
							</tr>
						</table>
					</td>
					<td style="vertical-align: top; font-family: Verdana, Tahoma, Arial; font-size: 10px; color: #000000;">&nbsp;</td>
				</tr>
			</table>
		</body>
	</html>
	';
    // obfuscate
    if (method_exists($exception, 'getObfuscate') && count($exception->getObfuscate()) != 0) {
        $output = str_replace($exception->getObfuscate(), '***', $output);
    }
    // custom callback?
    if (Spoon::getExceptionCallback() != '') {
        // function
        if (!strpos(Spoon::getExceptionCallback(), '::')) {
            // function actually has been defined
            if (function_exists(Spoon::getExceptionCallback())) {
                call_user_func_array(Spoon::getExceptionCallback(), array($exception, $output));
            } else {
                exit('The exception callback function (' . Spoon::getExceptionCallback() . ') could not be found.');
            }
        } else {
            // method
            $method = explode('::', Spoon::getExceptionCallback());
            // 2 parameters and exists
            if (count($method) == 2 && is_callable(array($method[0], $method[1]))) {
                call_user_func_array(array($method[0], $method[1]), array($exception, $output));
            } else {
                exit('The exception callback function (' . Spoon::getExceptionCallback() . ') cound not be found.');
            }
        }
    } else {
        // on CLI we have no use for 2000 lines long report, show short info
        if (Spoon::inCli()) {
            echo $name . "\n";
            echo 'Message: ' . $exception->getMessage() . "\n";
            echo 'File: ' . $exception->getFile() . "\n";
            echo 'Line: ' . $exception->getLine() . "\n";
        } elseif (Spoon::getDebug()) {
            echo $output;
        } else {
            echo Spoon::getDebugMessage();
        }
    }
    // mail it?
    if (Spoon::getDebugEmail() != '') {
        // e-mail headers
        $headers = "MIME-Version: 1.0\n";
        $headers .= "Content-type: text/html; charset=iso-8859-15\n";
        $headers .= "X-Priority: 3\n";
        $headers .= "X-MSMail-Priority: Normal\n";
        $headers .= "X-Mailer: SpoonLibrary Webmail\n";
        $headers .= "From: Spoon Library <no-reply@spoon-library.com>\n";
        // send email
        @mail(Spoon::getDebugEmail(), 'Exception Occured', $output, $headers);
    }
    // stop script execution
    exit;
}
開發者ID:jeroendesloovere,項目名稱:library,代碼行數:101,代碼來源:exception.php


注:本文中的Spoon::getExceptionCallback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。