The Input class provides a connection to GET
, POST
, PATCH
and PUT
variables, URL segments and page numbers.
The best way to get the Input variable is to use the input()
method of the Site class:
$input = Scriptor::getSite()->input();
Accessing GET, POST, PATCH, and PUT data
This is how you access the GET variable:
$username = $input->get->username;
Same thing for the POST, PATCH and PUT data:
$username = $input->post->username;
// $username = $input->patch->username;
// $username = $input->put->username;
If you access a variable that is not provided, then it returns null:
if (!$input->post->myCheckBox) {
// the $_POST['myCheckBox'] is not provided
}