zoukankan      html  css  js  c++  java
  • header的用法(PHP)


    注:此文章转自csdn网站,本文主要讲述用php语言来描述html中的header。
    标头 (header) 是服务器以 HTTP 协义传 HTML 资料到浏览器前所送出的字串,在标头与 HTML 文件之间尚需空一行分隔。有关 HTTP 的详细说明,可以参 RFC 2068 官方文件(http://www.w3.org/Protocols/rfc2068/rfc2068)。在 PHP 中送回 HTML 资料前,需先传完所有的标头。
    注意: 传统的标头一定包含下面三种标头之一,并只能出现一次。
    Content-Type: xxxx/yyyy
    Location: xxxx:yyyy/zzzz
    Status: nnn xxxxxx
    在新的多型标头规格 (Multipart MIME) 方可以出现二次以上。

    使用范例
    范例一: 本例使浏览器重定向到 PHP 的官方网站
    <?php
    Header("Location: http://www.php.net";); 
    exit;
    ?>
    范例二: 强制使用者每次都能得到最新的资料,而不是 Proxy 或 cache 中的资料(客户端的缓存),可以使用下列的标头
    <?php
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");//设置时间
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
    header("Cache-Control: no-cache, must-revalidate");//控制页面不使用缓存
    header("Pragma: no-cache");
    ?>
    范例三: 让使用者的浏览器出现找不到档案的信息,控制访问权限。
    <?php
    header("Status: 404 Not Found");
    ?>
    范例四:实现下载档案。<?php
    header("Content-type: application/x-gzip");
    header("Content-Disposition: attachment; filename=文件名");
    header("Content-Descrīption: PHP3 Generated Data");
    ?>
     

  • 相关阅读:
    beanutils中WrapDynaBean
    beanutils中Lazy
    beanutils中jdbc
    beanutils设置参数和获取参数
    beanutils获取带参数get方法
    beanutils通过SimpleProperty使用get或set方法赋值
    C3P0配置
    Codeforces Round #587 (Div. 3)
    Codeforces Round #589 (Div. 2)
    Codeforces Round #588 (Div. 2)
  • 原文地址:https://www.cnblogs.com/y0umer/p/2809564.html
Copyright © 2011-2022 走看看