I'm trying to automatically sanitize input on an array of global variables like so:
$sanitize = array('_POST', '_GET', '_REQUEST', '_COOKIE', '_SESSION');
foreach($sanitize as $type){
$property = trim(strtolower($type), '_');
$this->$property = $this->cleanse($$type);
}
But I get: Notice: Undefined variable: _REQUEST
(and so on for all of the global variables I'm trying)
Is doing what I'm trying to accomplish actually possible?
Thanks.
Doing this on a global scale is typically frowned upon.
I'd recommend using some of PHP's built in Filters to achieve what you want at a local level. That is just filter what you need as you need it.