<?php
header('HTTP/1.0 403 Forbidden');
?>
編碼:

 

<?php
header('Content-Type: text/html; charset=utf-8'); //使用utf-8編碼
?>
跳轉:

 

<?php
//header('Location: index.php'); //url最好用絕對路徑
header('Location: [url]HTTP://www.baidu.com/[/url]');
exit(); //不要省略,否則程式會把本頁解釋完後才跳轉。
?>
<?php
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
//$extra = 'admin/index.php';
$extra = 'rss.php';
header("Location: [url]HTTP://$host$uri/$extra[/url]");
exit;
?>
<?php
header('Refresh: 2; url=index.html');
echo '登錄成功!';
?>
檔下載:

 

<?php
$filename = "theDownloadedFileIsCalledThis.mp3";
$myFile = "/absolute/path/to/my/file.mp3"; //可以從資料庫讀取
$mm_type="application/octet-stream"; //可以用程式判斷後綴名
header("Cache-Control: public, must-revalidate");
header("Pragma: hack"); // WTF? oh well, it works...
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($myFile)) );
header('Content-Disposition: attachment; filename="'.$filename.'"'); //供下載時顯示用的,可不是真實值
header("Content-Transfer-Encoding: binary\n");
readfile($myFile);
?>
檔下載:

 

<?php
$filename = "theDownloadedFileIsCalledThis.mp3";
$myFile = "/absolute/path/to/my/file.mp3"; //可以從資料庫讀取
$mm_type="application/octet-stream"; //可以用程式判斷後綴名
header("Cache-Control: public, must-revalidate");
header("Pragma: hack"); // WTF? oh well, it works...
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($myFile)) );
header('Content-Disposition: attachment; filename="'.$filename.'"'); //供下載時顯示用的,可不是真實值
header("Content-Transfer-Encoding: binary\n");
readfile($myFile);
?>
禁用緩存:

 

<?PHP
// HTTP/1.0 and HTTP/1.1
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-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
?>

 

arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()