CodeIgniter Forums
New Request Class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: New Request Class (/showthread.php?tid=1266)



New Request Class - Dias - 02-24-2015

Hi.
I want to offer the use of a new class of global arrays.
I know that there is already a class Input, but not very useful. Input class does not clear the data and does not lead to the desired type.
I think this is a better solution than the input class:

PHP Code:
public post ([string $name], [string|array $filters], [mixed $default])
public 
get ([string $name], [string|array $filters], [mixed $default]) 

Example:

PHP Code:
$name $this->request->post('name', array('trim''striptags'));

$checked $this->request->post('checked''int'0);

$id $this->request->get('id''int'); 

As for XSS, I think the data must be escaped in a template, because there is a violation of data integrity, if it is done in Input Class.

If users will consider a class of useful I can show the class code.

Sorry for my english.


RE: New Request Class - includebeer - 02-28-2015

The form validation class already do that (filter, trim, etc)

As for data type, you can type cast the result : $id = (int)$this->input->get('id');