PHP

php的header函数怎么使用

小亿
102
2023-07-17 13:10:57
栏目: 编程语言
PHP开发者专用服务器,限时0元免费领! 查看>>

PHP的header()函数用于向浏览器发送原始的HTTP头信息。它通常用于重定向页面、设置响应状态码、设置缓存等操作。

语法:

header(string $header, bool $replace = true, int $http_response_code = null)

参数说明:

示例:

  1. 设置重定向:
header("Location: http://www.example.com");
  1. 设置响应状态码:
header("HTTP/1.1 404 Not Found");
  1. 设置缓存:
header("Cache-Control: no-cache, must-revalidate");

注意事项:

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

相关推荐:PHP header()函数的使用方法是什么

0
看了该问题的人还看了