php header函数详解
客户机的请求方式格式:是统一资源标识符、协议版本号,后边是MIME信息包括请求修饰符、客户机信息和可能的内容!服务器响应格式:一个状态行包括信息的协议版本号、一个成功或错误的代码,后边是MIME信息包括服务器信息、实体信息和可能的内容。
通常有一下三种:
Location: xxxx:yyyy/zzzz
Content-Type: xxxx/yyyy
Status: nnn xxxxxx
常用实例
1、实现重定向(状态302)
<?php
header("Location:http://www.baidu.com");
exit;
2、页面不存在(404页面)
<?php
header("HTTP/1.1 404 Not Found");
header("status:404 Not Found");
3、永久重定向
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location:http://www.baidu.com");
4、下载文件
<?php
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.zip"');
header('Content-Transfer-Encoding: binary');
5、设置文件类型
<?php
header('Content-Type: text/html; charset=utf-8'); header('Content-Type: text/plain'); header('Content-Type:image/jpeg'); header('Content-Type:application/zip'); header('Content-Type:application/pdf'); header('Content-Type:audio/mpeg'); header('Content-Type: application/x-shockwave-flash');
php header函数详解的更多相关文章
- php header 函数详解
网页的缓存是由 HTTP消息头中的“Cache-control”来控制的,常见的取值有private.no-cache.max-age.must- revalidate等,默认为private.其作用 ...
- windows socket函数详解
windows socket函数详解 近期一直用第三方库写网络编程,反倒是遗忘了网络编程最底层的知识.因而产生了整理Winsock函数库的想法.以下知识点均来源于MSDN,本人只做翻译工作.虽然很多前 ...
- PHP输出缓存ob系列函数详解
PHP输出缓存ob系列函数详解 ob,输出缓冲区,是output buffering的简称,而不是output cache.ob用对了,是能对速度有一定的帮助,但是盲目的加上ob函数,只会增加CPU额 ...
- loadrunner 脚本优化-关联函数web_reg_save_param()函数详解
脚本优化-关联函数web_reg_save_param()函数详解 by:授客 QQ:1033553122 Insert->New Step,打开Add Step对话框 选择函数web_re ...
- loadrunner 脚本开发- web_url函数详解
脚本开发- web_url函数详解 by:授客 QQ:1033553122 加载指定url的web页面(GET请求) C语言函数 int web_url( const char *StepName ...
- malloc 与 free函数详解<转载>
malloc和free函数详解 本文介绍malloc和free函数的内容. 在C中,对内存的管理是相当重要.下面开始介绍这两个函数: 一.malloc()和free()的基本概念以及基本用法: 1 ...
- NSSearchPathForDirectoriesInDomains函数详解
NSSearchPathForDirectoriesInDomains函数详解 #import "NSString+FilePath.h" @implementation ...
- JavaScript正则表达式详解(二)JavaScript中正则表达式函数详解
二.JavaScript中正则表达式函数详解(exec, test, match, replace, search, split) 1.使用正则表达式的方法去匹配查找字符串 1.1. exec方法详解 ...
- Linux C popen()函数详解
表头文件 #include<stdio.h> 定义函数 FILE * popen( const char * command,const char * type); 函数说明 popen( ...
随机推荐
- win8.1 vs2010 C++环境下 编译Android Adb.exe
1 IntelliSense: cannot open source file "usb100.h" adb 这是因为没有安装sdk造成的.win7下安装wdk,vs2010能够 ...
- Asp.net web api部署在某些服务器上老是404
asp.net web api部署在Windows服务器上后,按照WebAPI定义的路由访问,老是出现404,但定义一个静态文件从站点访问,却又OK. 这时,便可以确定是WebAPI路由出了问题,经调 ...
- python安装pycrypto报错error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
系统3.19.0-15-generic #15-Ubuntu 安装pycrypto提示error: command 'x86_64-linux-gnu-gcc' failed with exit st ...
- Vmware虚拟机克隆的网卡问题
系统环境:red hat 6.4 在虚拟机上使用克隆后,克隆机没有eth0, 出现eth1并且出错No suitable device found: no device found for conne ...
- [转]linux14.04下caffe的安装步骤
linux14.04下caffe的安装步骤 原文地址:http://blog.csdn.net/xiaoyang19910623/article/details/52997481?locatio ...
- ViewPager 仿 Gallery效果
xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android ...
- Apache安装配置步骤
注释:这里以Linux 红帽商业版为例~~~~~~~纯手打啊 Apache安装配置步骤 准备:关闭其他虚拟设备 #/etc/init.d/libvirtd stop #/etc/init.d/xend ...
- .NET调用window串口读取电子秤的数据
Private serialPort As SerialPort '定义 Public Function CreateSerialPort() As String Dim strWei ...
- 用scala实现一个sql执行引擎-(上)
前言 在实时计算中,通常是从队列中收集原始数据,这种原始数据在内存中通常是一个java bean,把数据收集过来以后,通常会把数据落地到数据库,供后面的ETL使用.举个一个简单的例子,对一个游戏来说, ...
- 关于调整浏览器窗口JS
有时候需要对浏览器窗口的大小进行元素的操控,当调整窗口大小时用window.onresize=function(){} 页面初始化window.onload=function(){} 要注意的是onr ...