Vesthelm Engine

2.1.1 User Guide

Input Class

The Input class pre-processes global input data for security.

Calling the Input Class

$Input = $this->Input;

Getting $_POST value

The first argument will contain the name of the $_POST item you are looking for:

$value = $this->Input->post('title');

The function returns empty string '' if the item you are attempting to retrieve does not exist.

The second argument will set specified value 'no_value' if the item you are attempting to retrieve does not exist:

$value = $this->Input->post('title', 'no_value'); //$value will be string 'no_value'

Getting $_GET value

The first argument will contain the name of the $_GET item you are looking for:

$value = $this->Input->get('title');

The function returns empty string '' if the item you are attempting to retrieve does not exist.

The second argument will set specified value 'no_value' if the item you are attempting to retrieve does not exist:

$value = $this->Input->get('title', 'no_value'); //$value will be string 'no_value'

Getting $_REQUEST value

The first argument will contain the name of the $_REQUEST item you are looking for:

$value = $this->Input->request('title');

The function returns empty string '' if the item you are attempting to retrieve does not exist.

The second argument will set specified value 'no_value' if the item you are attempting to retrieve does not exist:

$value = $this->Input->request('title', 'no_value'); //$value will be string 'no_value'

Getting $_SERVER value

The first argument will contain the name of the $_SERVER item you are looking for:

$value = $this->Input->server('title');

The function returns empty string '' if the item you are attempting to retrieve does not exist.

The second argument will set specified value 'no_value' if the item you are attempting to retrieve does not exist:

$value = $this->Input->server('title', 'no_value'); //$value will be string 'no_value'

Setting Global Value

The first argument 'title' will contain the name of the item. Second argument 'Test' will be item value. Third argument 'post' is the global method name.

$this->Input->set('title', 'Test', 'post'); //$_POST['title'] = 'Test';

$this->Input->set('title', 'Test', 'get'); //$_GET['title'] = 'Test';

$this->Input->set('title', 'Test', 'cookie'); //$_COOKIE['title'] = 'Test';

The function returns false if method does not exist.