hearder函数常用实例

    xiaoxiao2021-04-18  66

    一、可用作网页跳转 header("location:http://blog.csdn.net/zhaozzeng/");

    二、定义编码

    header( 'Content-Type:text/html;charset=utf-8 ');

    三、强制禁止客户端浏览器缓存header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header("Cache-Control: no-cache");header("Pragma: no-cache");四、输出页面表格 header('Content-type: application/xls'); header('Content-Disposition: attachment; filename=文件名.xls'); echo $table(表格字符串) 五、以PDF格式下载当前页面 header("Content-type:application/pdf"); header("Content-Disposition:attachment;filename='文件名.pdf'"); 六、输出json格式字符串 header('Content-Type: application/json; charset=utf-8'); echo json_encode($array); 七、文件延迟转向:

    header('Refresh: 10; url=http://blog.csdn.net/zhaozzeng/');

    八、提供简单的图片下载支持 url为绝对路径 header('Content-type: application/force-download'); header('Content-Transfer-Encoding: Binary'); header('Content-length: '.filesize($url)); header('Content-disposition: attachment; filename='.basename($url)); readfile($url); 九、网页出错处理 // 301 header("Location:http://blog.csdn.net/zhaozzeng/",TRUE,301); 、// 302header("Location:http://blog.csdn.net/zhaozzeng/",TRUE,302);// 303header("Location:http://blog.csdn.net/zhaozzeng/",TRUE,303);// 307 header("Location:http://blog.csdn.net/zhaozzeng/",TRUE,307); // 404 header("Location:http://blog.csdn.net/zhaozzeng/",TRUE,404); ........
    转载请注明原文地址: https://ju.6miu.com/read-675650.html

    最新回复(0)