详情页

php如何设置响应头

时间:2023年10月05日

编辑:佚名

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、重定向(跳转到其它网页)
header('Location:https://www.baidu.com');//跳转到百度网页
?>
3、下载文件
<?php
header('Content-Type:application/octet-stream');//设置文件下载
header('Content-Disposition:attachment;filename=dome.txt');
?>
相关文章
猜你需要