本文整理汇总了PHP中header::status方法的典型用法代码示例。如果您正苦于以下问题:PHP header::status方法的具体用法?PHP header::status怎么用?PHP header::status使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类header
的用法示例。
在下文中一共展示了header::status方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$endpoint = $this;
if ($page = page('webmention') and kirby()->path() == $page->uri()) {
if (r::is('post')) {
try {
$endpoint->start();
header::status(202);
tpl::set('status', 'success');
tpl::set('alert', null);
} catch (Exception $e) {
header::status(400);
tpl::set('status', 'error');
tpl::set('alert', $e->getMessage());
}
} else {
tpl::set('status', 'idle');
}
} else {
kirby()->routes(array(array('pattern' => 'webmention', 'method' => 'GET|POST', 'action' => function () use($endpoint) {
try {
$endpoint->start();
echo response::success('Yay', 202);
} catch (Exception $e) {
echo response::error($e->getMessage());
}
})));
}
}
示例2: header
/**
* Sends the correct header for the response
*
* @param boolean $send If set to false, the header will be returned
* @return mixed
*/
public function header($send = true)
{
$status = header::status($this->code, false);
$type = header::type($this->format, 'utf-8', false);
if (!$send) {
return $status . PHP_EOL . $type;
}
header($status);
header($type);
}
示例3: error
public static function error($message, $type, $file, $line)
{
// remove everything that has been rendered so far
if (ob_get_level()) {
ob_end_clean();
}
if (class_exists('kirby') and !is_null(kirby::$instance)) {
$kirby = kirby::$instance;
} else {
$kirby = null;
}
if (r::ajax()) {
if (terror::debug()) {
echo response::error($message, 400, array('type' => $type, 'file' => $file, 'line' => $line));
} else {
echo response::error('Unexpected error', 400);
}
} else {
header::status(400);
static::view($message, $type, $file, $line, $kirby);
}
die;
}
示例4: launch
/**
* Starts the router, renders the page and returns the response
*
* @return mixed
*/
public function launch()
{
// this will trigger the configuration
$site = $this->site();
// force secure connections if enabled
if ($this->option('ssl') and !r::secure()) {
// rebuild the current url with https
go(url::build(array('scheme' => 'https')));
}
// set the timezone for all date functions
date_default_timezone_set($this->options['timezone']);
// load all extensions
$this->extensions();
// load all plugins
$this->plugins();
// load all models
$this->models();
// start the router
$this->router = new Router($this->routes());
$this->route = $this->router->run($this->path());
// check for a valid route
if (is_null($this->route)) {
header::status('500');
header::type('json');
die(json_encode(array('status' => 'error', 'message' => 'Invalid route or request method')));
}
// call the router action with all arguments from the pattern
$response = call($this->route->action(), $this->route->arguments());
// load all language variables
// this can only be loaded once the router action has been called
// otherwise the current language is not yet available
$this->localize();
// build the response
$this->response = $this->component('response')->make($response);
// store the current language in the session
if ($this->site()->multilang() && ($language = $this->site()->language())) {
s::set('language', $language->code());
}
return $this->response;
}
示例5: headers
/**
* Sends all appropriate headers for this page
* Can be configured with the headers config array,
* which should contain all header definitions for each template
*/
public function headers()
{
$template = $this->template();
if (isset($this->kirby->options['headers'][$template])) {
$headers = $this->kirby->options['headers'][$template];
if (is_numeric($headers)) {
header::status($headers);
} else {
if (is_callable($headers)) {
call($headers, $this);
}
}
} else {
if ($this->isErrorPage()) {
header::notfound();
}
}
}
示例6: response
public function response()
{
// this will trigger the configuration
$site = $this->site();
$router = new Router($this->routes());
$route = $router->run($this->path());
// check for a valid route
if (is_null($route)) {
header::status('500');
header::type('json');
die(json_encode(array('status' => 'error', 'message' => 'Invalid route or request method')));
}
$response = call($route->action(), $route->arguments());
if (is_string($response)) {
$this->response = static::render(page($response));
} else {
if (is_array($response)) {
$this->response = static::render(page($response[0]), $response[1]);
} else {
if (is_a($response, 'Response')) {
$this->response = $response;
} else {
if (is_a($response, 'Page')) {
$this->response = static::render($response);
} else {
$this->response = null;
}
}
}
}
return $this->response;
}