Re: Native support - PUT request, multipart form data

From: Date: Sun, 17 Aug 2014 20:14:38 +0000
Subject: Re: Native support - PUT request, multipart form data
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-76612@lists.php.net to get a copy of this message
As a variant, not to create a new super global variables, can be modified $_REQUEST to OOP style class _REQUEST implements ArrayAccess // for backward compatibility { .... } // get as array, from body request $_REQUEST->body // get all http request headers $_REQUEST->headers // get method request - POST, PUT... $_REQUEST->method // get Content-Type: multipart/form-data or application/json or ... $_REQUEST->type // get Content-Length request $_REQUEST->length It looks nice, but in practice it is more convenient to use an global array - $_DATA or $_BODY or $_INPUT. You can also do: class _INPUT implements ArrayAccess { public function get($name, $default = null) { if(isset($this->data[$name]) { return $this->data[$name]; } else { return $default; } } public function filter($name, $filter = FILTER_DEFAULT, $options = null) { return filter_var($this->data[$name], $filter, $options); } } Examples: $value = $_INPUT->get('varName1', 'myDefaultValue'); $email = $_INPUT->filter('varName2', FILTER_SANITIZE_EMAIL); 2014-08-17 3:25 GMT+03:00 Andrea Faulds <ajf@ajf.me>: > > On 17 Aug 2014, at 00:47, Park Framework <park.framework@gmail.com> wrote: > >> Variable $_PUT is already a popular name. > > $_POST isn’t really POST data nor is $_GET really GET data. We shouldn’t continue this > silly naming tradition given both existing names are inaccurate. > > We should have a query parameters array and a request body parameters array or blob. > -- > Andrea Faulds > http://ajf.me/ > > > >

« previous php.internals (#76612) next »