易截截图软件、单文件、免安装、纯绿色、仅160KB

php中的header用法

 header() is used to send raw HTTP headers. See the HTTP/1.1 specification for more information on HTTP headers.
使用范例
范例一:
 <?PHP
Header("Location: http://www.phpchina.com";);
exit;//在每个重定向之后都必须加上“exit",避免发生错误后,继续执行。
?>
<?php
header("refresh:2;url=http://www.baidu.com");
echo "正在加载,请稍等...<br>三秒后自动跳转至<a href="http://www.baidu.com" mce_href="http://www.baidu.com">百度</a>...";
?>
范例二:禁止页面在IE中缓存
使浏览者每次都能得到最新的资料,而不是 Proxy 或 cache 中的资料:
<?PHP
header( 'Expires: Fri, 4 Dec 2009 09:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' ); //兼容http1.0和https
?>
CacheControl = no-cache  Pragma=no-cache  Expires = -1
如果服务器上的网页经常变化,就把Expires设置为-1,表示立即过期。如果一个网页每天凌晨1点更新,可以把Expires设置为第二天的凌晨1点。当HTTP1.1服务器指定CacheControl = no-cache时,浏览器就不会缓存该网页。
旧式 HTTP 1.0 服务器不能使用 Cache-Control 标题。所以为了向后兼容 HTTP 1.0 服务器,IE使用Pragma:no-cache 标题对 HTTP 提供特殊支持。如果客户端通过安全连接 (https://) 与服务器通讯,且服务器在响应中返回 Pragma:no-cache 标题,则 Internet Explorer 不会缓存此响应。
注意:Pragma:no-cache 仅当在安全连接中使用时才防止缓存,如果在非安全页中使用,处理方式与 Expires:-1 相同,该页将被缓存,但被标记为立即过期。
http-equiv meta标记:
在html页面中可以用http-equiv meta来标记指定的http消息头部。老版本的IE可能不支持html meta标记,所以最好使用http消息头部来禁用缓存。
范例三: 让使用者的浏览器出现找不到档案的信息。
网上很多资料这样写: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 (


相关文档:

php分页

<?php
//分页
$link=mysql_connect("localhost","root","root");
$db=mysql_select_db("bustest",$link);
$res=mysql_query("select * from info");
//一共多少条
$count=mysql_num_rows($res);
//每页5条信息
$perpage=5;
//一共多少页
$pagecount=ceil($count/$perpage);
//传过来的页数
$pagenum=$_REQUE ......

PHP生日计算

      腾讯的QQ空间根据会员资料计算生日并提醒好友发送生日祝福,一些网站也有类似的功能,比如提前几天向会员发送祝福邮件。
大致过程如下:设置一个自动执行程序,比如Linux下可以用CronTab 实现。此程序每天执行一次读取会员资料中的birth_day,
判断是否符合设置的发送要求。假如设置提前三 ......

PHP中的stristr(),strstr(),strpos()速度比较


PHP中的stristr(),strstr(),strpos()速度比较

测速代码:

<?php
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
......

php的static变量作用域

对于运行在apache里的php应用来说,static变量的作用域是一次http请求。
可以通过以下代码进行验证:
<?php
# test.php
function test(){
     static $sss = 0;
     ++$sss;
     echo $sss;
}
test();
?>
访问/test.php ,可以看到,总是 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号