本文整理汇总了PHP中ErrorHandler::customHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::customHandler方法的具体用法?PHP ErrorHandler::customHandler怎么用?PHP ErrorHandler::customHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler::customHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run($page = false, $db = false, $options = [])
{
ErrorHandler::$customHandler = function ($errno, $errstr, $errfile, $errline, $errcontext, $errorName) {
$controller = new ApiController();
$controller->errorResponse("Unknown Error", "{$errorName} {$errstr}", "{$errfile} on line {$errline}");
};
parent::run($page, $db, $options);
}
示例2: runAction
function runAction()
{
ErrorHandler::$customHandler = function ($errno, $errstr, $errfile, $errline, $errcontext, $errorName) {
$this->fail("{$errorName} {$errstr}\n{$errfile} on line {$errline}");
print '<hr>';
print "<p>\n Aborted with <span id=\"test-status-pass-count\">{$this->passCount}</span> passe" . ($this->passCount == 1 ? '' : 's') . ",\n <span id=\"test-status-fail-count\">{$this->failCount}</span> fail" . ($this->failCount == 1 ? '' : 's') . ".\n </p>";
$this->printFoot();
exit;
};
try {
$files = $this->testFiles();
$testFile = $files[$_GET['test']];
if (!$testFile) {
die('cannot find test');
}
$this->__testFile = $testFile;
$this->__buffered = preg_match('/-with-buffer.php/', $testFile);
if ($this->__buffered) {
ob_start();
}
$this->printHead();
print '<h3>' . htmlentities($this->nameForTestFile($testFile)) . '</h3>';
$relativePath = substr($testFile, strlen(Env::get('base_path')));
print "<pre>{$relativePath}</pre>";
print '<hr>';
print '<p><a href="test.php">« Back to test list</a></p>';
print '<hr>';
print '<ul id="test-list">';
require $testFile;
print '</ul>';
print '<hr>';
print "<p>\n Completed with <span id=\"test-status-pass-count\">{$this->passCount}</span> passe" . ($this->passCount == 1 ? '' : 's') . ",\n <span id=\"test-status-fail-count\">{$this->failCount}</span> fail" . ($this->failCount == 1 ? '' : 's') . ".\n </p>";
$this->printFoot();
if ($this->__buffered) {
ob_end_flush();
}
} catch (\Exception $e) {
$this->fail('Exception: ' . $e->getMessage() . "\n" . $e->getTraceAsString());
print '<hr>';
print "<p>\n Aborted with <span id=\"test-status-pass-count\">{$this->passCount}</span> passe" . ($this->passCount == 1 ? '' : 's') . ",\n <span id=\"test-status-fail-count\">{$this->failCount}</span> fail" . ($this->failCount == 1 ? '' : 's') . ".\n </p>";
$this->printFoot();
exit;
}
}