找人建站做网站需要注意什么问题,网站建设的线框图叫什么,wordpress 前台 上传,公众号网站怎么建我们在实际开发中经常使用header()实现一些功能#xff0c;这篇文章介绍关于header()的7中用法#xff0c;需要的伙伴的开参考一下。 PHP header()的7中用法#xff1a;
1、跳转页面
可以使用header()实现跳转页面功能。
header(Location:.$url); // $url 跳转页面的地址…我们在实际开发中经常使用header()实现一些功能这篇文章介绍关于header()的7中用法需要的伙伴的开参考一下。 PHP header()的7中用法
1、跳转页面
可以使用header()实现跳转页面功能。
header(Location:.$url); // $url 跳转页面的地址2、声明 content-type
调用API接口时一般都会声明 content-type 的类型否则无法读写数据。 header(content-type:text/html;charsetutf-8);
header(content-type:application/json;charsetutf-8);3、返回response状态码 header(HTTP/1.1 404 Not Found);4、定时执行跳转
header(Refresh: 10; urlhttp://www.baidu.com/); //10s后跳转。在这里插入代码片5、控制浏览器缓存 header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
header(Last-Modified: . gmdate(D, d M Y H:i:s) . GMT);
header(Cache-Control: no-cache, must-revalidate);
header(Pragma: no-cache);6、执行http验证 header(HTTP/1.1 401 Unauthorized);
header(WWW-Authenticate: Basic realmTop Secret);7、下载 header(Content-Type: application/octet-stream); //设置内容类型
header(Content-Disposition: attachment; filenameexample.zip); //设置MIME用户作为附件
header(Content-Transfer-Encoding: binary); //设置传输方式
header(Content-Length: .filesize(example.zip)); //设置内容长度