php tips

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:[email protected]/1001/咖哩辣椒/咖喱辣椒.rmvb");
.......2006-10-08 13:26:45

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章