本文整理汇总了PHP中ErrorHandler::primitiveError方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::primitiveError方法的具体用法?PHP ErrorHandler::primitiveError怎么用?PHP ErrorHandler::primitiveError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler::primitiveError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: traverse
public final function traverse($URL)
{
$pages = $this->getPages();
if (!is_null($pages) and $pages !== false) {
foreach ($pages as $Page) {
if (!is_null($Page) && $Page instanceof Page && $Page->isMatch($URL)) {
try {
$Page->run($this);
$Page->show($this);
return null;
} catch (Exception $e) {
ErrorHandler::primitiveError(500, "Page script error", $e->getMessage());
}
}
}
}
ErrorHandler::primitiveError(404, "Page not found", "Cannot find any pages with this URL.");
}
示例2: ob_clean
ob_clean();
$errorCase = array(E_WARNING => "Warning!", E_ERROR => "Error!", E_USER_ERROR => "User Error", E_USER_WARNING => "User Warning", E_USER_NOTICE => "User Notice");
self::primitiveError(500, array_key_exists($errno, $errorCase) ? $errorCase[$errno] : "An unknown error occurred", $errstr . "<br/>Line " . $errline . " in " . $errfile);
}
public static function fatalHandler()
{
$error = error_get_last();
if (self::$Enabled && $error !== null) {
$errorMsg = $error['message'] . ' on line ' . $error['line'] . "<br/>(" . $error['file'] . ")";
self::primitiveError(500, "Fatal error occurred", $errorMsg);
}
}
private static $Enabled = false;
public static function start()
{
error_reporting(0);
self::$Enabled = true;
set_error_handler(__CLASS__ . '::exceptionHandler', E_ALL);
register_shutdown_function(__CLASS__ . '::fatalHandler');
}
public static function stop()
{
self::$Enabled = false;
error_reporting(E_ALL);
restore_error_handler();
register_shutdown_function("exit");
}
}
ErrorHandler::start();
@(include_once "engine/Engine.php") or ErrorHandler::primitiveError(500, "Missing Engine class.");
$engine = new Engine();
示例3: run
public function run()
{
try {
//Traverse the Template if possible, otherwise the template is null;
if (is_null(self::$currentTemplate)) {
throw new Exception("No template found.");
} else {
$url = $this->fixPath(isset($_GET["current_engine_page"]) ? $_GET["current_engine_page"] : "");
self::$currentTemplate->traverse($url);
}
} catch (Exception $e) {
ErrorHandler::primitiveError(500, "Cannot run Engine", $e->getMessage());
}
}