php header()函数使用说明

2019-04-10 18:48:05刘景俊

//告诉客户端浏览器不使用缓存
header("Cache-Control: no-cache, must-revalidate");
//参数(与以前的服务器兼容),即兼容HTTP1.0协议
header("Pragma: no-cache");
//输出MIME类型
header("Content-type: application/file");
//文件长度
header("Content-Length: 227685");
//接受的范围单位
header("Accept-Ranges: bytes");
//缺省时文件保存对话框中的文件名称
header("Content-Disposition: attachment; filename=$filename");
?>
   

   <3>  输出状态值到浏览器,主要用于访问权限控制   

<?php
header('HTTP/1.1 401 Unauthorized');
header('status: 401 Unauthorized');
?>
   
           比如要限制一个用户不能访问该页,则可设置状态为404,如下所示,这样浏览器就显示为即该页不存在  

<?php
header('HTTP/1.1 404 Not Found');
header("status: 404 Not Found");
?>
相关文章 大家在看