php - Best practices to deal with absent/wrongly typed GET variables? -
When you find that your request has been broken or the wrong type of data is passing, what do you do? Say you have a forum-page Php? Forum = 3 which lists all the topics related to stage 3.
What would be a good way to deal with the lack of "forum" variables? Instead of being an integer, you get a string?
Do not really love to read your opinion about this.
I usually return a 400 (bad request) state status (for example "Stage parameter is required"). Not sure if PHP allows this (ASP.NET), but then you can map to a 400 on a custom page that displays the error in the way that your app understands.
Comments
Post a Comment