mckay / httpstatus

简单易用的HTTP状态。

v1.0.6 2015-05-07 23:28 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:27:42 UTC


README

HTTP状态类的常量。

安装

将其添加到您的composer.json中

"mckay/httpstatus": "^1.0.4",

然后运行 $ composer update

使用方法

use \McKay\HttpStatus;

if (!$user->isRoot()) {
	renderView(...);
	HttpStatus::set(HttpStatus::UNAUTHORIZED);
	return;
}

if (empty($resource)) {
	renderError(...);
	HttpStatus::set(HttpStatus::NOT_FOUND);
	return;
}

function renderError(...) {
	$code = HttpStatus::get();
	$description = HttpStatus::text();
	...
}

查看源代码以获取可用的HTTP状态常量的完整列表。

许可

版权所有 © McKay Software
MIT许可
http://mckay.mit-license.org