本文整理汇总了PHP中LogicException::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP LogicException::getMessage方法的具体用法?PHP LogicException::getMessage怎么用?PHP LogicException::getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogicException
的用法示例。
在下文中一共展示了LogicException::getMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handler
/**
* 显示exception错误信息
* @param LogicException $e
*/
function handler($e)
{
if ($e->getCode() == 404 && !DEBUG) {
header("HTTP/1.0 404 Not Found");
exit;
}
// 正式情况下
$this->out['_msg'] = $e->getMessage();
$this->out['_code'] = $e->getCode();
// 只有LogicException才需要显示详细,记录日志
if ($e instanceof LogicException) {
// DEBUG时显示调试详细信息
if (DEBUG) {
$this->out['_exception_detail']['trace'] = $this->getTraceDesc($e->getTrace());
$this->out['_exception_detail']['file'] = $e->getFile();
$this->out['_exception_detail']['line'] = $e->getLine();
} else {
$this->out['_msg'] = '系统错误';
}
}
if (!$this->tpl) {
$this->tpl = PATH_APP . '/template/msg.tpl';
}
$this->display();
}
示例2: __toString
/**
* Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg:
* $foo = new Message( $key );
* $string = "<abbr>$foo</abbr>";
*
* @since 1.18
*
* @return string
*/
public function __toString()
{
if ($this->format !== 'parse') {
$ex = new LogicException(__METHOD__ . ' using implicit format: ' . $this->format);
\MediaWiki\Logger\LoggerFactory::getInstance('message-format')->warning($ex->getMessage(), ['exception' => $ex, 'format' => $this->format, 'key' => $this->key]);
}
// PHP doesn't allow __toString to throw exceptions and will
// trigger a fatal error if it does. So, catch any exceptions.
try {
return $this->toString();
} catch (Exception $ex) {
try {
trigger_error("Exception caught in " . __METHOD__ . " (message " . $this->key . "): " . $ex, E_USER_WARNING);
} catch (Exception $ex) {
// Doh! Cause a fatal error after all?
}
if ($this->format === 'plain' || $this->format === 'text') {
return '<' . $this->key . '>';
}
return '<' . htmlspecialchars($this->key) . '>';
}
}