本文整理汇总了PHP中Spoon::inCli方法的典型用法代码示例。如果您正苦于以下问题:PHP Spoon::inCli方法的具体用法?PHP Spoon::inCli怎么用?PHP Spoon::inCli使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spoon
的用法示例。
在下文中一共展示了Spoon::inCli方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;"> </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 . ' » 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;"> </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;
}
示例2: getName
public function getName()
{
return $this->name;
}
/**
* Return an array of elements that need to be obfuscated.
*
* @return array
*/
public function getObfuscate()
{
return $this->obfuscate;
}
}
// Redefine the exception handler if we are not running in the command line.
if (!Spoon::inCli()) {
set_exception_handler('exceptionHandler');
}
/**
* Prints out the thrown exception in a more readable manner for a person using
* a web browser.
*
* @param SpoonException $exception
*/
function exceptionHandler($exception)
{
// fetch trace stack
$trace = $exception->getTrace();
// specific name
$name = is_callable(array($exception, 'getName')) ? $exception->getName() : get_class($exception);
// spoon type exception