本文整理匯總了PHP中Header::send方法的典型用法代碼示例。如果您正苦於以下問題:PHP Header::send方法的具體用法?PHP Header::send怎麽用?PHP Header::send使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Header
的用法示例。
在下文中一共展示了Header::send方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: render
public function render()
{
$layout = $this->content_for_template();
$body = $this->content_for_layout($layout);
// Needed for testing
if (CUPCAKE_ENV === "test") {
$dispatcher = DispatcherTest::getInstance();
$dispatcher->__params = $this->view_params();
$dispatcher->__view_params = $this->view_params;
$dispatcher->__template = $this->template;
$dispatcher->__layout = $this->layout;
# Action might be false positive and controller aswell.
$dispatcher->__controller = $this->controller;
$dispatcher->__action = $this->params["action"];
$dispatcher->__request_uri = $this->request_uri;
$dispatcher->__body = $body;
return;
}
if (!empty($this->content_type)) {
Header::set("Content-Type", $this->content_type);
Header::send();
}
echo $body;
exit;
}
示例2: redirect_to
public function redirect_to($url, $status = 302)
{
$this->save_session();
$codes = $this->status_code;
if (!empty($status)) {
if (is_string($status)) {
$codes = array_combine(array_values($codes), array_keys($codes));
}
if (isset($codes[$status])) {
$code = $msg = $codes[$status];
if (is_numeric($status)) {
$code = $status;
}
if (is_string($status)) {
$msg = $status;
}
Header::set_raw("HTTP/1.1 {$code} {$msg}");
$status = "HTTP/1.1 {$code} {$msg}";
} else {
$status = null;
}
}
if ($url !== null) {
Header::set("Location", "{$url}");
}
if (CUPCAKE_ENV !== "test") {
Header::send();
}
exit;
}
示例3:
<?php
/**
* Дополнительная настройка
*/
/**
* Доп. заголовки
*/
Header::send('X-Powered-By: Knee');
/**
* Указание языка
*/
Lang::setLocale('ru');