Why doesn't http_response_code header?

if (true)
 header("HTTP/1.0 404 Not Found");

or
if (true)
 http_response_code(404);

In the developer tools shows that a 404 response code, but the page still loaded. How to make so that the page didn't load?
June 5th 19 at 21:34
1 answer
June 5th 19 at 21:36
Solution
add exit; after sending the header:
if (true) {
 header("HTTP/1.0 404 Not Found");
exit;
}

Find more questions by tags PHP