国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

PHP header函數(shù)分析詳解

2024-05-04 23:17:25
字體:
供稿:網(wǎng)友
在php語言中,header()這個函數(shù)很有用的,尤其在用到ajax時候,他會幫你解決一些意想不到的問題。下面是header的一些詳細(xì)講解。希望對phper有幫助

復(fù)制代碼 代碼如下:


<?php
// fix 404 pages:
header('HTTP/1.1 200 OK');
// set 404 header:
header('HTTP/1.1 404 Not Found');
// set Moved Permanently header (good for redrictions)
// use with location header
header('HTTP/1.1 301 Moved Permanently');
// redirect to a new location:
header('Location: ');
// redrict with delay:
header('Refresh: 10; url=http://www.example.org/');
print 'You will be redirected in 10 seconds';
// you could also use the HTML syntax:// <meta http-equiv="refresh" content="10; />
// override X-Powered-By: PHP:
header('X-Powered-By: PHP/4.4.0');
header('X-Powered-By: Brain/0.6b');
// content language (en = English)
header('Content-language: en');
// last modified (good for caching)
$time = time() – 60; // or filemtime($fn), etc
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
// header for telling the browser that the content
// did not get changed
header('HTTP/1.1 304 Not Modified');
// set content length (good for caching):
header('Content-Length: 1234');
// Headers for an download:
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.zip"');
header('Content-Transfer-Encoding: binary');
// load the file to send:readfile('example.zip');
// Disable caching of the current document:
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// Date in the pastheader('Pragma: no-cache');
// set content type:
header('Content-Type: text/html; charset=iso-8859-1');
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain');
// plain text file
header('Content-Type: image/jpeg');
// JPG picture
header('Content-Type: application/zip');
// ZIP file
header('Content-Type: application/pdf');
// PDF file
header('Content-Type: audio/mpeg');
// Audio MPEG (MP3,…) file
header('Content-Type: application/x-shockwave-flash');
// Flash animation// show sign in box
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
print 'Text that will be displayed if the user hits cancel or ';
print 'enters wrong login data';
?>


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 阳原县| 阿克| 宜黄县| 化德县| 德庆县| 怀来县| 郧西县| 秀山| 准格尔旗| 安国市| 九龙坡区| 潼南县| 宁夏| 晋中市| 广昌县| 那坡县| 交城县| 玛沁县| 河北省| 六安市| 象山县| 杨浦区| 中阳县| 衡东县| 汉阴县| 玉溪市| 奇台县| 灵武市| 沾化县| 高淳县| 区。| 建昌县| 民勤县| 保康县| 印江| 桐乡市| 安泽县| 扎赉特旗| 宁南县| 方正县| 理塘县|