You can do pretty much anything you want in the constructor. Having said that, it doesn't mean you should. Many would argue that anything meaningful or that could throw an exception should not be in a constructor. Anyways, If you are going to use this class you could do something like this:
class qwerty
{
private $get;
public function __construct($params)
{
$this->get = $this->sanitize($params);
}
public function sanitize($params)
{
$sanitized = $params;
foreach ($sanitized as $key => $value) {
$sanitized[$key] = strip_tags($value);
}
return $sanitized;
}
public function getField($field)
{
if (array_key_exists($field,$this->get)) {
return $this->get[$field];
} else {
return null;
}
}
}
$q = new qwerty($_GET);
$q->getField('id');