本文整理汇总了PHP中Exception::getStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getStatus方法的具体用法?PHP Exception::getStatus怎么用?PHP Exception::getStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::getStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStatus
public function getStatus()
{
if ($this->exception instanceof HttpError) {
return $this->exception->getStatus();
}
return WebResponse::STATUS_SERVER_ERROR;
}
示例2: test_getStatus_returnsInt_ifStatusDoesExist
/**
* getStatus() should return int if status does exist
*/
public function test_getStatus_returnsInt_ifStatusDoesExist()
{
$status = 500;
$exception = new Exception();
$exception->setStatus($status);
$this->assertEquals($status, $exception->getStatus());
return;
}
示例3: setHeaderStatus
/**
* Send the $exception's code or $code as the formal HTTP status of the response.
*
* @param integer $code suggested HTTP response code, if exception fails to provide one
* @param Exception $exception OPTIONAL HTTP status code
* @return string status code and description
*/
private static function setHeaderStatus($code, Exception $exception = null)
{
if ($exception instanceof ZFDemo_Exception_Reroute) {
$status = $exception->getStatus();
} else {
switch ($code) {
case 404:
$status = '404 Not Found';
break;
case 500:
$status = '500 Internal Server Error';
break;
default:
require_once 'Zend/Http/Response.php';
$status = $code . ' ' . Zend_Http_Response::responseCodeAsText($code);
}
}
if ('cgi' !== substr(php_sapi_name(), 0, 3) && !empty($_SERVER['SERVER_PROTOCOL'])) {
header($_SERVER['SERVER_PROTOCOL'] . ' ' . $status, true);
} else {
header('Status: ' . $status, true);
}
return $status;
}
示例4: setException
/**
* @param \Exception $exception
* @throws \Exception
* @return self
*/
public function setException(\Exception $exception)
{
if ($exception instanceof Exception && null !== $exception->getStatus()) {
$this->setStatus($exception->getStatus())->setContent($exception->getMessage() . "\n");
} else {
throw $exception;
}
return $this;
}