Search code examples
phphttphttp-status-codeshttp-status-code-403http-status-code-415

HTTP Status Codes in a PHP Application


I recently decided to send proper HTTP header from my PHP application.
Since I've never done that before, I have a couple of very basic questions.

Status codes 200 and 404 seem obvious.
But how about the other ones?

Is it allowed to/recommended/not recommended to use 403 for example, if the user has to log in via a HTML form in order to use the page?

How about 415 for file uploads? Would it be a good idea to set a 415 header if the user uploads an image with a non-supported extension, for example?


Solution

  • The full list of W3C recognised codes is here. The definitions contain clear guidance on when each code should and should not be used. Your suggested use of 403, for example, is at odds with the W3C definition.