PHP returns HTTP status code
Many people ask me this during the interview, record the??? 200 is OK,?? 404 indicates that the page was not found.
HTTP protocol status code, call the function only need to give $num to a known value in the following table will return the state directly.
/**?
*? HTTP? Protocol?defined?status?codes
*? HTTP protocol status code, call the function only need to give $num to a known value in the following table will return the state directly.
* @param? int? $num
*/?
Function?https ($num)? {?
$http? =?array? (?
100?=>? " Http/1.1?100? Continue ",?
101?=>? " Http/1.1?101? Switching? Protocols ",?
200?=>? " Http/1.1?200? OK, "?
201?=>? " Http/1.1?201? Created ",?
202?=>? " Http/1.1?202? Accepted ",?
203?=>? " Http/1.1?203? Non-authoritative? Information ",?
204?=>? " Http/1.1?204? No? Content ",?
205?=>? " Http/1.1?205? Reset? Content ",?
206?=>? " Http/1.1?206? Partial? Content ",?
300?=>? " Http/1.1?300? Multiple? Choices ",?
301?=>? " http/1.1?301? Moved? Permanently ",?
302?=>? " Http/1.1?302? Found ",?
303?=>? " Http/1.1?303? See? Other ",?
304?=>? " http/1.1?304? Not? Modified ",?
305?=>? " Http/1.1?305? Use? Proxy ",?
307?=>? " Http/1.1?307? Temporary? Redirect ",?
400?=>? " Http/1.1?400? Bad? Request ",?
401?=>? " Http/1.1?401? Unauthorized ",?
402?=>? " Http/1.1?402? Payment? Required ",?
403?=>? " Http/1.1?403? Forbidden ",?
404?=>? " Http/1.1?404? Not? Found ",?
405?=>? " Http/1.1?405? Method? Not? Allowed ",?
406?=>? " Http/1.1?406? Not? Acceptable ",?
407?=>? " http/1.1?407? Proxy? Authentication? Required ",?
408?=>? " http/1.1?408? Request? Time-out ",?
409?=>? " http/1.1?409? Conflict ",?
410?=>? " Http/1.1?410? Gone ",?
411?=>? " Http/1.1?411? Length? Required ",?
412?=>? " http/1.1?412? Precondition? Failed ",?
413?=>? " http/1.1?413? Request? Entity? Too? Large ",?
414?=>? " Http/1.1?414? Request-uri? Too? Large ",?
415?=>? " Http/1.1?415? Unsupported? Media? Type ",?
416?=>? " http/1.1?416? Requested?range?not?satisfiable ",?
417?=>? " Http/1.1?417? Expectation? Failed ",?
500?=>? " Http/1.1?500? Internal? Server? Error ",?
501?=>? " http/1.1?501? Not? Implemented ",?
502?=>? " http/1.1?502? Bad? Gateway, "?
503?=>? " http/1.1?503? Service? Unavailable ",?
504?=>? " http/1.1?504? Gateway? Time-out "??
);?
Header ($http [$num]);?
}?
?>
@header (
' http/1.0?404? Not? Found '
);
?
?
?
?
?