I’m making a system that needs to be able to accept input from both get and post and process accordingly. I want to avoid $_REQUEST because some of our servers aren’t configured to use it and I don’t want to micromanage that. What I’d like to know is if it’s bad practice to do something like this:
switch ($_SERVER['REQUEST_METHOD']) {
case 'POST':
$this->_process($_POST);
break;
case 'GET':
$this->_process($_GET);
break;
}
*Ignore the lack of preprocessing of post data for now
Checking the method of the request is exactly what
$_SERVER['REQUEST_METHOD']is intended for. So no problem with that.This value is actually part of the CGI specification and should therefore be provided by any decent webserver: