return a specific http status code with php [dupli

2019-02-22 05:56发布

问题:

This question already has an answer here:

  • PHP: How to send HTTP response code? 7 answers

Is there a way to have a php script return a specific http status code rather than relying on apache to do it?

回答1:

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

http://php.net/header



回答2:

You can set header values manually with php, for example:

<?php
header("HTTP/1.0 404 Not Found");
?>


标签: php http