January 24th, 2011, 09:16 AM
If($_SERVER['REQUEST_METHOD']=="GET") vs if (isset($_POST
i have recently taken over a project from another developer, and something he had done boggled me a bit as i have never used it before
basically he used if($_SERVER['REQUEST_METHOD']=="GET") and i always use if (isset($_POST
now the application its self was to be a facbook app and the if($_SERVER['REQUEST_METHOD']=="GET") did not work so me changing it to if (isset($_POST worked in the FB tab.
i suppose my question is why would you use 1 over the other
January 24th, 2011, 09:42 AM
PHP hasn't always had $_GET and $_POST
It used to be $_REQUEST
and there was a precedence order as to what you would get in $_REQUEST['foo'] if a varibale called foo was sent in both get and post parts of the request.
Given that get and post are semantically different, it makes sense to a developer to know which method was used to send the data to the script, so you would look for the request method to choose what you wanted to do with the data.
Basically, it's code from php versions < 4
Comments on this post
January 26th, 2011, 08:25 AM
thanks for the information on the above 2 helped alot
Originally Posted by Northie