本文整理汇总了PHP中Header::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Header::set方法的具体用法?PHP Header::set怎么用?PHP Header::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Header
的用法示例。
在下文中一共展示了Header::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}