I want to set http response code according to condition in php page.
if($Variable== true)
{
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
include('404.php');
die();
}
I am looking something like below.
if($Variable == true)
// http response code =404
else
// http response code =200
Is it possible to do this thing in php?
I have tried as below to solve it. But not worked.
if($Variable ==true)
{
http_response_code(404);
include('404.php');
die();
}