php中header函数的使用
header("HTTP/1.0 400 Bad Request"); 返回400错误
header("HTTP/1.0 404 Not Found"); 返回404错误
header("Location:http://$host$uri/$extra"); 跳转
//设置nocache ,过期
header
(
"Cache-Control: no-cache,
must-revalidate"
);
//
HTTP/1.1
header
(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT"
);
// Date in the past
?>
?>
header,php
1。PHP header() 函数
网上很多资料这样写:php的函数header()可以向浏览器发送Status标头,如 header("Status: 404 Not Found")。
但是我发现实际上浏览器返回的响应却是:
HTTP/1.x 200 OK
Date: Thu, 03 Aug 2006 07:49:11 GMT
Server: Apache/2.0.55 (Win32) PHP/5.0.5
X-Powered-By: PHP/5.0.5
Status:
404 Not Found
Content-Length: 0
Keep-Alive: timeout=15, max=98
Connection: Keep-Alive
Content-Type: text/html
查了一些资料,正确的写法是:
header("http/1.1
404 Not Found");
第一部分为HTTP协议的版本(HTTP-Version);第二部分为状态代码(Status);第三部分为原因短语(Reason-Phrase)。若要想让浏览器不是从 Proxy 或 cache 中取得页面,可以使用下列的标头
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");
具体含义下面解释。
2。禁止页面在IE中缓存
http响应消息头部设置:
CacheControl = no-cache
Pragma=no-cache
Expires = -1
[color=#000000]Expires是个好东东,如果服务器上的网页经常变化,就把它设置为-1,表示立即过期。如果一个网页每天凌晨1点更新,可以把
[/color][color=#000000]Expires
[/color][color=#000000]设置为第二天的凌晨1点。
当HTTP1.1服务器指定
[/color]CacheControl = no-cache[color=#000000]时,浏览器就不会缓存该网页。
[/color]旧式 HTTP 1.0 服务器不能使用 Cache-Control 标题。所以为了向后兼容 HTTP 1.0 服务器,IE使用Pragma:no-cache
标题对 HTTP 提供
相关文档:
login。php听说要用个第三方页面来实现跳转。说是为了安全方面的考虑。我再想想吧~
先把代码贴出来
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta h ......
常量可以理解为值不变的变量。常量值被定义后,在脚本的其他任何地方都不能被改变。一个常量由英文字母、下划线、和数字组成,但 数字不能作为首字母出现。
在php中使用defaine()函数来定义常量,该函数的语法格式为:
define(string constant_name, mixed value, case_sensitive = true)
该函数有3个参数:
cons ......
APC是一种php的缓存解决方案,目前以pecl方式发布,有消息说将会出现在php6版本的内核.
一.安装方法
1)从http://pecl.php.net/package/apc下载相应版本
2)解压
3)进入源码目录
4)执行php安装目录下的bin/phpize
5)./configure --enable-apc --enable-apc-mmap --with-apxs=path-to-apache/bin/apxs --with-php-config=p ......
- -! 真不容易啊,弄了一天,终于搞定了!
在ubuntu9.04下安装,首先要准备的东西很多,大部分是用来支持php的库,废话不多说,写这个也是为了便于我以后查看用,记忆不行,咳。。有需要的朋友也可以来去用。
在ubuntu上安装,有一个好处就是有新立得这个软件,首先先安装mysql, ......