PHP

php中header的用法是什么

小亿
83
2024-01-24 19:52:13
栏目: 编程语言

在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

0
看了该问题的人还看了