首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

header下令学习笔记

2012-12-24 
header命令学习笔记注意: 传统的标头一定包含下面三种标头之一,并只能出现一次。* Content-Type: xxxx/yyyy

header命令学习笔记

注意: 传统的标头一定包含下面三种标头之一,并只能出现一次。    * Content-Type: xxxx/yyyy    * Location: xxxx:yyyy/zzzz    * Status: nnn xxxxxx范例一: 本例用来重导用户到 PHP 的官方网站。Header("Location: http://www.php.net");  exit;范例二: 欲让用户每次都能得到最新的资料,而不是 Proxy 或 cache 中的资料,可以使用下列的标头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-cache, must-revalidate");header("Pragma: no-cache");范例三: 让用户的浏览器出现找不到文件的信息。header("Status: 404 Not Found");范例四: 提供让用户下载文件的范例。header("Content-type: application/x-gzip");header("Content-Disposition: attachment; filename=some-file.tar.gz");header("Content-Description: PHP3 Generated Data");其它:header("Content-type:text/gif;");header("Content-Type: text/html; charset=gb2312");header("Content-type: text/xml");PHP header常用指令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');  // 显示登录对话框,可以用来进行HTTP认证// 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';  <style type="text/css" > </style><style type="text/javascript" > </style>
?

?

热点排行