搜索
首页后端开发PHP问题php header函数怎么设置HTTP头

php header函数怎么设置HTTP头

Nov 04, 2020 am 11:31 AM
headerhttpphp

php header函数设置HTTP头的方法:【header( 'Content-Type:text/html;charset=utf-8 ');】,表示设置编码为utf-8。

php header函数怎么设置HTTP头

PHP header函数设置HTTP头的示例如下:

(视频教程推荐:java视频教程

定义编码

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

设置一个404头:

header('HTTP/1.1 404 Not Found');

设置地址被永久的重定向

header('HTTP/1.1 301 Moved Permanently');

转到一个新地址

header('Location: http://www.example.org/');

文件延迟转向:

header('Refresh: 10; url=http://www.example.org/');
print 'You will be redirected in 10 seconds';

告诉浏览器最后一次修改时间

$time = time() - 60; // or filemtime($fn), etc
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');

对当前文档禁用缓存

header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');

相关推荐:php培训

以上是php header函数怎么设置HTTP头的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

将Eclipse与SAP NetWeaver应用服务器集成。

VSCode Windows 64位 下载

VSCode Windows 64位 下载

微软推出的免费、功能强大的一款IDE编辑器

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用