PHP header函数使用大全
2015-03-20 13:13
253 查看
PHP header函数大全
header('Content-Type: text/html; charset=utf-8');
header('Location: http://blog.snsgou.com/');
view
source
?
header('Content-Type: text/html; charset=utf-8');
header('Location: http://blog.snsgou.com/');
view
source
?
01 | <?php |
02 | // fix 404 pages: |
03 | header( 'HTTP/1.1 200 OK' ); |
04 |
05 | // set 404 header: |
06 | header( 'HTTP/1.1 404 Not Found' ); |
07 |
08 | // set Moved Permanently header ('good for redrictions') |
09 | // use with location header |
10 | header( 'HTTP/1.1 301 Moved Permanently' ); |
11 |
12 | // redirect to a new location: |
13 | header( 'Location:); | ' target='_blank'>http://blog.snsgou.com/'[/code]
14 |
15 | // redrict with delay: |
16 | header( 'Refresh: 10; url=http://blog.snsgou.com/' ); |
17 | //print You will be redirected in 10 seconds; |
18 |
19 | // you could also use the HTML syntax:// <meta http-equiv="refresh" content="10;http://blog.snsgou.com/ /> |
20 |
21 | // override X-Powered-By: PHP: |
22 | header( 'X-Powered-By: PHP/4.4.0' ); |
23 | header( 'X-Powered-By: Brain/0.6b' ); |
24 |
25 | // content language ('en = English') |
26 | header( 'Content-language: en' ); |
27 |
28 | // last modified ('good for caching') |
29 | $time = time( '' ) – 60; // or filemtime('$fn'), etc |
30 | header( 'Last-Modified: .gmdate("D, d M Y H:i:s, ' . $time . '"). GMT' ); |
31 |
32 | // header for telling the browser that the content |
33 | // did not get changed |
34 | header( 'HTTP/1.1 304 Not Modified' ); |
35 |
36 | // set content length ('good for caching'): |
37 | header( 'Content-Length: 1234' ); |
38 |
39 | // Headers for an download: |
40 | header( 'Content-Type: application/octet-stream' ); |
41 | header( 'Content-Disposition: attachment; filename="example.zip"' ); |
42 | header( 'Content-Transfer-Encoding: binary' ); |
43 |
44 | // load the file to send:readfile('example.zip'); |
45 | // Disable caching of the current document: |
46 | header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' ); |
47 | header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); |
48 | // Date in the pastheader('Pragma: no-cache'); |
49 |
50 | // set content type: |
51 | header( 'Content-Type: text/html; charset=iso-8859-1' ); |
52 | header( 'Content-Type: text/html; charset=utf-8' ); |
53 | header( 'Content-Type: text/plain' ); |
54 |
55 | // plain text file |
56 | header( 'Content-Type: image/jpeg' ); |
57 |
58 | // JPG picture |
59 | header( 'Content-Type: application/zip' ); |
60 |
61 | // ZIP file |
62 | header( 'Content-Type: application/pdf' ); |
63 |
64 | // PDF file |
65 | header( 'Content-Type: audio/mpeg' ); |
66 |
67 | // Audio MPEG ('MP3,…') file |
68 | header( 'Content-Type: application/x-shockwave-flash' ); |
69 |
70 | // Flash animation// show sign in box |
71 | header( 'HTTP/1.1 401 Unauthorized' ); |
72 | header( 'WWW-Authenticate: Basic realm="Top Secret"' ); |
73 | //print Text that will be displayed if the user hits cancel or ; |
74 | //print enters wrong login data; |
75 | ?> |
相关文章推荐
- PHP header函数使用大全
- 【ZZ】一些在php中使用header函数设置http头的示例方法
- php中使用header函数后,页面提示:Warnging: Cannot modify header information - headers already sent by 错误的的原因
- Php header()函数及其常见使用
- php中header函数参数的Cache-control:private,no-cache,must-revalidate,max-age是使用方法!
- PHP header函数使用教程
- php header()函数使用详解
- php header()函数使用说明
- (转载)PHP使用header函数设置HTTP头的示例方法表头
- PHP 使用header函数设置HTTP头的示例方法 表头
- Php header()函数语法及使用代码
- 【转】PHP 使用header函数设置HTTP头的示例方法 表头
- PHP 使用header函数设置HTTP头的示例方法 表头
- 分享PHP header函数使用教程
- php header()函数使用说明
- PHP header()函数的使用
- php header()函数使用说明
- PHP header()函数使用详细(301、404等错误设置)
- PHP header函数使用教程
- PHP header函数使用教程