本文整理汇总了PHP中response::setCode方法的典型用法代码示例。如果您正苦于以下问题:PHP response::setCode方法的具体用法?PHP response::setCode怎么用?PHP response::setCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类response
的用法示例。
在下文中一共展示了response::setCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* 入口点
*/
function run()
{
$response = new response();
$cacheConfig = config('cache');
if ($cacheConfig['cache']) {
$cache = cache::getInstance($cacheConfig);
$content = $cache->check($this->http->url());
if (!empty($content)) {
$response->setBody($content);
$response->send();
}
}
try {
$handler = $this->parseUrl();
if (is_array($handler)) {
list($control, $action) = $handler;
$path = ROOT . '/application/control/' . $control . '.php';
if (file_exists($path)) {
include $path;
$class = 'application\\control\\' . $control . 'Control';
if (class_exists($class)) {
//$class = new \ReflectionClass($class);
$class = new $class();
$class->response =& $response;
if (method_exists($class, $action) && is_callable(array($class, $action)) || method_exists($class, '__call')) {
$response->setCode(200);
$response->setBody($this->__200($class, $action));
} else {
$response->setCode(404);
$response->setBody($this->__404($control, $action));
}
} else {
$response->setCode(404);
$response->setBody($this->__404($control, $action));
}
} else {
$response->setCode(404);
$response->setBody($this->__404($control, $action));
}
} else {
include ROOT . '/application/thread/' . $handler . '.php';
$class = 'application\\thread\\' . $handler . 'Thread';
$class = new $class();
$class->run();
}
} catch (\Exception $e) {
$response->setCode(500);
$response->setBody($this->__500($e));
} finally {
$response->send();
}
}