PHP

php中header的用法是什么

小亿
94
2024-01-24 19:52:13
栏目: 编程语言
PHP开发者专用服务器,限时0元免费领! 查看>>

在PHP中,header函数用于发送原始的HTTP头部。

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

参数:

示例用法:

  1. 设置 Content-Type
header("Content-Type: application/json");
  1. 重定向到指定网址
header("Location: https://example.com");
  1. 设置 HTTP 响应代码
header("HTTP/1.1 404 Not Found");

注意事项:

更多详细信息,请参考PHP官方文档:https://www.php.net/manual/zh/function.header.php

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

相关推荐:php header函数的用法是什么

0
看了该问题的人还看了