5.关于表单刷新
问:为什么我在点击浏览器的后退按钮后,所有字段的信息都被清空了?
答:这是由于你在你的表单提交页面中使用了 session_start 函数。该函数会强制当前页面不被缓存。解决办法为,在你的 Session_start 函数后加入 header("Cache-control: private"); 注意在本行之前你的PHP程序不能有任何输出。
补充:还有基于session的解决方法,在session_start前加上
session_cache_limiter('nocache');// 清空表单
session_cache_limiter('private'); //不清空表单,只在session生效期间
session_cache_limiter('public'); //不清空表单,如同没使用session一般
可以在session_start();前加上 session_cache_limiter("private,max-age=10800");
摘自phpe.net
----
6.快速搞定文件下载头部输出
header("Content-type: application/x-download");
header("Content-Disposition: attachment; filename=$file_download_name;");
header("Accept-Ranges: bytes");
header("Content-Length: $download_size");
echo 'xxx'
.......2004-08-19 11:50:30
----
7.用header输出ftp下载方式,并且支持断点续传
一个例子:
header('Pragma: public');
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header('Accept-Ranges: bytes');
header('Connection: close');
header("Content-Type: audio/mpeg");
header("Location:ftp://download:1bk3l4s3k9s2@218.30.116.103/1001/咖哩辣椒/咖喱辣椒.rmvb");
.......2006-10-08 13:26:45
php tips
最新推荐文章于 2025-04-16 06:32:38 发布