本文整理汇总了PHP中error_get_last函数的典型用法代码示例。如果您正苦于以下问题:PHP error_get_last函数的具体用法?PHP error_get_last怎么用?PHP error_get_last使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error_get_last函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _shutdownHandler
/**
* Shutdown handler for log fatal errors
*/
public static function _shutdownHandler()
{
$error = error_get_last();
if (self::$sendErrors && in_array($error['type'], self::$unrecoverable)) {
Rollbar::report_exception($error);
}
}
示例2: handleFatalError
/**
* 处理致命错误
*/
function handleFatalError()
{
if ($e = error_get_last()) {
$msg = $e['message'] . " in " . $e['file'] . ' line ' . $e['line'];
log_message('error', 'PHP Fatal error: ' . $msg);
}
}
示例3: test_admin_panel_edit_user
/**
* @covers Starter\routers\RestRouter::admin_panel_edit_user
*/
public function test_admin_panel_edit_user()
{
ob_start();
$this->router->admin_panel_edit_user(1);
ob_end_clean();
self::assertNull(error_get_last());
}
示例4: shutdown
/**
* shutdown函数,用于捕获至命错误
*/
function shutdown()
{
$error = error_get_last();
if ($error) {
show_error($error['message'], $error['type'], $error['file'], $error['line']);
}
}
示例5: breathe_shutdown_function
/**
*
*/
function breathe_shutdown_function()
{
$error = error_get_last();
if ($error !== null) {
error::Ret()->Log('breathe_shutdown_function: ' . print_r($error, true));
}
}
示例6: check_for_fatal
/**
* Checks for a fatal error, work around for set_error_handler not working on fatal errors.
*/
function check_for_fatal()
{
$error = error_get_last();
if ($error["type"] == E_ERROR) {
errorHandler($error["type"], $error["message"], $error["file"], $error["line"]);
}
}
示例7: handleFatal
/**
* Log fatal error to Mautic's logs and throw exception for the parent generic error page to catch
*
* @throws \Exception
*/
public function handleFatal()
{
$error = error_get_last();
if ($error !== null) {
$name = $this->getErrorName($error['type']);
$this->logger->error("{$name}: {$error['message']} - in file {$error['file']} - at line {$error['line']}");
if ($error['type'] === E_ERROR || $error['type'] === E_CORE_ERROR || $error['type'] === E_USER_ERROR) {
defined('MAUTIC_OFFLINE') or define('MAUTIC_OFFLINE', 1);
if (MAUTIC_ENV == 'dev') {
$message = "<pre>{$error['message']} - in file {$error['file']} - at line {$error['line']}</pre>";
// Get a trace
ob_start();
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$trace = ob_get_contents();
ob_end_clean();
// Remove first item from backtrace as it's this function which
// is redundant.
$trace = preg_replace('/^#0\\s+' . __FUNCTION__ . "[^\n]*\n/", '', $trace, 1);
// Renumber backtrace items.
$trace = preg_replace('/^#(\\d+)/me', '\'#\' . ($1 - 1)', $trace);
$submessage = "<pre>{$trace}</pre>";
} else {
$message = 'The site is currently offline due to encountering an error. If the problem persists, please contact the system administrator.';
$submessage = 'System administrators, check server logs for errors.';
}
include __DIR__ . '/../../../../offline.php';
}
}
}
示例8: run
/**
* Run application
*
* @return bool|\Phalcon\Http\ResponseInterface
*/
public function run()
{
$this->_initLoader($this->_dependencyInjector);
$this->_initServices($this->_dependencyInjector, $this->config);
$this->_initModule();
$handle = $this->handle();
if ($this->config->logError) {
$error = error_get_last();
if ($error) {
$logKey = md5(implode('|', $error));
/**
* @var $corePhpLog CorePhpLogs
*/
$corePhpLog = CorePhpLogs::findFirst(['conditions' => 'log_key = ?0', 'bind' => [$logKey]]);
if ($corePhpLog) {
$corePhpLog->status = 0;
} else {
$corePhpLog = new CorePhpLogs();
$corePhpLog->assign(['log_key' => $logKey, 'type' => $error['type'], 'message' => $error['message'], 'file' => $error['file'], 'line' => $error['line'], 'status' => 0]);
}
$corePhpLog->save();
}
}
return $handle;
}
示例9: __construct
public function __construct($filename = null, array $options = array(), $binary = false, $type = null)
{
$this->filename = $filename;
$this->remote = false;
$this->binary = (bool) $binary;
$this->assertFileAvaiable();
$this->detectFormat($type);
if ($this->binary) {
$this->oldImage = @imagecreatefromstring($this->filename);
} else {
switch ($this->format) {
case self::TYPE_PNG:
$this->oldImage = @imagecreatefrompng($this->filename);
break;
case self::TYPE_JPEG:
$this->oldImage = @imagecreatefromjpeg($this->filename);
break;
case self::TYPE_GIF:
$this->oldImage = @imagecreatefromgif($this->filename);
break;
}
}
if (!$this->oldImage) {
$error = error_get_last();
throw new \InvalidArgumentException('create image with given resource failed' . ($error ? ' with error ' . $error['message'] : ''));
}
$this->currentDimensions = array('width' => imagesx($this->oldImage), 'height' => imagesy($this->oldImage));
$this->setOptions($options);
}
示例10: sgfun
function sgfun($filter, $params = null)
{
$fp = fopen('php://memory', 'w');
$filter = @stream_filter_append($fp, $filter, STREAM_FILTER_WRITE, $params);
if ($filter === false) {
fclose($fp);
$error = error_get_last() + array('message' => '');
throw new RuntimeException('Unable to access built-in filter: ' . $error['message']);
}
// append filter function which buffers internally
$buffer = '';
sgappend($fp, function ($chunk) use(&$buffer) {
$buffer .= $chunk;
// always return empty string in order to skip actually writing to stream resource
return '';
}, STREAM_FILTER_WRITE);
$closed = false;
return function ($chunk = null) use($fp, $filter, &$buffer, &$closed) {
if ($closed) {
throw new RuntimeException('Unable to perform operation on closed stream');
}
if ($chunk === null) {
$closed = true;
$buffer = '';
fclose($fp);
return $buffer;
}
// initialize buffer and invoke filters by attempting to write to stream
$buffer = '';
fwrite($fp, $chunk);
// buffer now contains everything the filter function returned
return $buffer;
};
}
示例11: shutdown
/**
* Método executado quando ocorre algum erro fatal no PHP, esse método é chamado
* antes que o PHP pare a execução da página
* @return void
*/
public static function shutdown()
{
$error = error_get_last();
if (is_array($error)) {
self::handle($error['type'], $error['message'], $error['file'], $error['line']);
}
}
示例12: tierShutdownFunction
/**
* This fatal error shutdown handler will only get called when there is a serious fatal
* error with your application.
*/
public static function tierShutdownFunction()
{
$fatals = [E_ERROR, E_PARSE, E_USER_ERROR, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING];
$lastError = error_get_last();
if (empty($lastError) !== true && in_array($lastError['type'], $fatals) === true) {
if (headers_sent() === true) {
return;
}
extract($lastError);
$msg = sprintf("Fatal error: %s in %s on line %d", $message, $file, $line);
$preStyles = ["color: red", "white-space: pre-wrap", "white-space: -moz-pre-wrap", "white-space: -pre-wrap", "white-space: -o-pre-wrap", "word-wrap: break-word"];
$preStyle = implode(";", $preStyles);
$html = <<<HTML
<html>
<body>
<h1>500 Internal Server Error</h1>
<hr/>
<pre style='%s'>%s</pre>
</body>
</html>
HTML;
$output = sprintf($html, $preStyle, $msg);
$body = new HtmlBody($output, 500);
self::sendRawBodyResponse($body);
}
}
示例13: createTrace
public function createTrace($type = null, $message = null, $file = null, $line = null, $custom_data = array())
{
if (empty($type)) {
$e = error_get_last();
if (!empty($e)) {
$message = $e['message'];
$file = $e['file'];
$type = $e['type'];
$line = $e['line'];
}
}
if (!empty($type)) {
$levels = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice');
// Set error type
$type = isset($levels[$type]) ? $levels[$type] : 'Unknown';
// Fetch router
$router =& load_class('Router', 'core');
// Set up the trace file (1 level is better than none)
$trace = array();
$trace[0] = array();
$trace[0]['function'] = $router->fetch_method();
$trace[0]['class'] = $router->fetch_class();
$trace[0]['type'] = $type;
$trace[0]['args'] = array();
$trace[0]['file'] = $file;
$trace[0]['line'] = $line;
// Send to airbrake
self::sendToTracker($type . ': ' . $message, $type, $trace, $custom_data);
}
}
示例14: setUpExceptionHandler
/**
* @inheritdoc
*/
protected function setUpExceptionHandler(SapiInterface $sapi, ContainerInterface $container)
{
error_reporting(E_ALL);
$createHandler = function () use($container) {
$has = $container->has(ExceptionHandlerInterface::class);
$handler = $has === true ? $container->get(ExceptionHandlerInterface::class) : new DefaultHandler();
return $handler;
};
$throwableHandler = function (Throwable $throwable) use($sapi, $container, $createHandler) {
/** @var ExceptionHandlerInterface $handler */
$handler = $createHandler();
$handler->handleThrowable($throwable, $sapi, $container);
};
$exceptionHandler = function (Exception $exception) use($sapi, $container, $createHandler) {
/** @var ExceptionHandlerInterface $handler */
$handler = $createHandler();
$handler->handleException($exception, $sapi, $container);
};
set_exception_handler(PHP_MAJOR_VERSION >= 7 ? $throwableHandler : $exceptionHandler);
set_error_handler(function ($severity, $message, $fileName, $lineNumber) use($exceptionHandler) {
$errorException = new ErrorException($message, 0, $severity, $fileName, $lineNumber);
$exceptionHandler($errorException);
throw $errorException;
});
// handle fatal error
register_shutdown_function(function () use($container, $createHandler) {
$error = error_get_last();
if ($error !== null && (int) $error['type'] & (E_ERROR | E_COMPILE_ERROR)) {
/** @var ExceptionHandlerInterface $handler */
$handler = $createHandler();
$handler->handleFatal($error, $container);
}
});
}
示例15: log_error
function log_error($param)
{
$logdir = APP_ROOT . APP_DIR . '/webroot/data/logs/';
if (!is_dir($logdir)) {
return;
}
$error = error_get_last();
function_exists('fastcgi_finish_request') && fastcgi_finish_request();
if (!is_array($error) || !in_array($error['type'], array(E_ERROR, E_COMPILE_ERROR, E_CORE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR))) {
return;
}
$error = '';
$error .= date('Y-m-d H:i:s') . '--';
//$error .= 'Type:' . $error['type'] . '--';
$error .= 'Msg:' . $error['message'] . '--';
$error .= 'File:' . $error['file'] . '--';
$error .= 'Line:' . $error['line'] . '--';
$error .= 'Ip:' . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0') . '--';
$error .= 'Uri:' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . '--';
$error .= empty($_SERVER['CONTENT_TYPE']) ? '' : 'Content-Type:' . $_SERVER['CONTENT_TYPE'] . '--';
$error .= $_SERVER['REQUEST_METHOD'] . $_SERVER['REQUEST_URI'];
$error .= '<br/>';
$size = file_exists($file) ? @filesize($file) : 0;
file_put_contents($logdir . $param['file'], $error, $size < $param['maxsize'] ? FILE_APPEND : null);
}