【发布时间】:2019-09-06 15:48:43
【问题描述】:
我想根据php页面中的条件设置http响应码。
if($Variable== true)
{
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
include('404.php');
die();
}
我看起来像下面这样。
if($Variable == true)
// http response code =404
else
// http response code =200
在php中可以做这件事吗?
我已经尝试如下解决它。但没用。
if($Variable ==true)
{
http_response_code(404);
include('404.php');
die();
}
【问题讨论】:
-
http_response_code(404); -
尝试但得到 200 个响应代码。