james123 Posted June 13, 2015 Share Posted June 13, 2015 I'm used to using $_POST to handle my form data. In chapter 2, Mr Ullman states to use $_REQUEST. I did look up $_REQUEST on php.net and it says that it contains data for $_GET, $_POST, and $_COOKIE. Does that mean I no longer need to bother with $_GET or $_POST and just use $_REQUEST going forward? Sorry for the amateur question. I've done some PHP programming in the past and I'm trying to get back into it (hopefully in the correct way). Thank, James Link to comment Share on other sites More sharing options...
Larry Posted June 13, 2015 Share Posted June 13, 2015 Hey! You should use $_POST if you know it's a POST request (the same for $_GET). I expect I use $_REQUEST in Chapter 2 as an easy, foolproof introduction, but will switch to $_POST in due time. Sorry for any confusion! Link to comment Share on other sites More sharing options...
james123 Posted June 13, 2015 Author Share Posted June 13, 2015 Thank you for the clarification. I've used $_GET, $_POST, and $_COOKIE before, but never $_REQUEST. When would $_REQUEST be useful? thanks, James Link to comment Share on other sites More sharing options...
Larry Posted June 15, 2015 Share Posted June 15, 2015 $_REQUEST is useful primarily in two situations. First,for debugging purposes, it's easy to dump out this value. Second, if you have a page that could be passed a value via both GET and POST, $_REQUEST makes sense. Most commonly, this would be the ID of an item being updated. Link to comment Share on other sites More sharing options...
Recommended Posts