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 <[email protected]>:
>
> On 17 Aug 2014, at 00:47, Park Framework <[email protected]> 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/
>
>
>
>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php