Welcome Guest, Not a member yet? Register   Sign In
New Request Class
#1

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.
Reply
#2

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');
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB