php开源嘛
首页 | English | MySql数据库 | Php编程 | 建站杂烩 | 系统服务器 | 资源共享 | 专题 | 才桀网 | 支持论坛
  当前位置:主页>Php编程>文章内容
在PHP中如何使用header发送头部信息
来源:phpe.net 作者:本站整理 发布时间:2007-08-12  

在PHP中如何使用header发送头部信息phma.com

在照彭武兴先生的《PHP BIBLE》中所述,header可以送出Status标头,如
<?php

header("Status: 404 Not Found"); phma.com

?>

就可以让用户浏览器出现文件找不到的404错误,但是我试了这样是不行的。

后来我到w3.org上查了http的相关资料,终于试出来了如何Header出状态代码(Status),与大家分享。

其实应该是这样的:

Header("http/1.1 403 Forbidden");

?>

第一部分为HTTP协议的版本(HTTP-Version) phma.com

第二部分为状态代码(Status)

第三部分为原因短语(Reason-Phrase)

三部分中间用一个空格分开,且中间不能有回车,第一部分和第二部分是必需的,第三部分则是给人看的,可写可不写甚至乱写。

还有,这一句的输出必须在Html文件的第一行。

下面我给出各代码所代表的意思(是从w3.org上查到的,够权威了):

  * 1xx: Informational - Request received, continuing process

  * 2xx: Success - The action was successfully received, understood, phma.com

  and accepted

  * 3xx: Redirection - Further action must be taken in order to

  complete the request

  * 4xx: Client Error - The request contains bad syntax or cannot be

  fulfilled

  * 5xx: Server Error - The server failed to fulfill an apparently
phma.com
  valid request


       | "100" ; Continue

       | "101" ; Switching Protocols

       | "200" ; OK

       | "201" ; Created

       | "202" ; Accepted

       | "203" ; Non-Authoritative Information

       | "204" ; No Content

       | "205" ; Reset Content

       | "206" ; Partial Content

       | "300" ; Multiple Choices

       | "301" ; Moved Permanently

       | "302" ; Moved Temporarily

       | "303" ; See Other

       | "304" ; Not Modified

       | "305" ; Use Proxy

       | "400" ; Bad Request

       | "401" ; Unauthorized

       | "402" ; Payment Required

       | "403" ; Forbidden

       | "404" ; Not Found

       | "405" ; Method Not Allowed

       | "406" ; Not Acceptable

       | "407" ; Proxy Authentication Required

       | "408" ; Request Time-out

       | "409" ; Conflict

       | "410" ; Gone

       | "411" ; Length Required

       | "412" ; Precondition Failed

       | "413" ; Request Entity Too Large

       | "414" ; Request-URI Too Large

       | "415" ; Unsupported Media Type

       | "500" ; Internal Server Error

       | "501" ; Not Implemented

       | "502" ; Bad Gateway

       | "503" ; Service Unavailable

       | "504" ; Gateway Time-out

       | "505" ; HTTP Version not supported

文章来源: phpe.net
(阅读次数:
上一篇:MySQL 的数据类型和建库策略   下一篇:怎样为网站更好地建设出高质量的链接
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论
  热点文章
·PHP生成验证码图片的源代码
·PHP会话对(Session)使用入门
·Php部分常见问题总结[bug]
·php正则表达式的快速学习方法
·高手传经:学习PHP重在坚持
·用php生成静态页面的php函数
·PHP对文本数据库的基本操作方法
·用 PHP 读取文件的正确方法
·讲解PHP+MySQL的分页显示示例
·用PHP构建一个简易监视引擎
·我是怎样打造简单的PHP&MYSQL留
·用PHP实现表单验证码登陆校验
  相关文章
·PHP 编程语言开发动态 WAP 页面
·SSH与PHP相连接 确保传输数据的
·PHP支持页面回退的两种方法
·GD库安装问题详解之动态网页技术
·PHP编程中计算时间差的几种方法
·PHP生成验证码图片的源代码
·动态网页技术PHP中参数引用返回
·PHP中与数组相关的函数摘录
·PHP实现任意字符集下正常显示网
·我是怎样打造简单的PHP&MYSQL留
·一些PHP学习过程中的心得和经验:
·IIS 6 的 PHP 最佳配置方法

关于我们 | 本站声明 | 友情连接 | 诚邀加盟 | 网站地图
版权Power by DedeCms   技术支持QQ =>> 罗江游鱼   Jacking  后台登陆
Copyright @ 2007 公司地址:柳州市东环路268号 邮编:545006 电话:15920389818 桂ICP备07006725号