PHP

php的header函数怎么使用

小亿
90
2023-07-17 13:10:57
栏目: 编程语言

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");

注意事项:

0
看了该问题的人还看了