php设置响应头的方法:1、设置响应头文件类型,语句如“header('Content-Type:text/css;charset=GBK');”;2、设置重定向;3、设置文件下载。
php设置响应头
1、设置响应头文件类型<?php
header('Content-Type:text/css;charset=GBK');//css文件类型,GBK编码
header('Content-Type:text/html;charset=UTF-8');//html文件类型,UTF-8类型
header('Content-Type:text/plain');//纯文件类型,不会做任何解析
header('Content-Type:applcation/javascript');//javascript文件类型
?>
2、重定向(跳转到其它网页)<?php
header('Location:https://www.baidu.com');//跳转到百度网页
?>
3、下载文件<?php
header('Content-Type:application/octet-stream');//设置文件下载
header('Content-Disposition:attachment;filename=dome.txt');
?>
推荐:《PHP教程》