It is a simple library developed to retrieve user inputs by prioritizing or verifying.
- PHP 7.4 or higher
- InitPHP ParameterBag
- InitPHP Validation
composer require initphp/input
require_once "vendor/autoload.php";
use \InitPHP\Input\Input;
// echo isset($_GET['name']) ? $_GET['name'] : 'John';
echo Input::get('name', 'John');
require_once "vendor/autoload.php";
use \InitPHP\Input\Input;
/**
* if(isset($_GET['year']) && $_GET['year'] >= 1970 && $_GET['year'] <= 2070){
* $year = $_GET['year'];
* }elseif(isset($_POST['year']) && $_POST['year'] >= 1970 && $_POST['year'] <= 2070){
* $year = $_POST['year'];
* }else{
* $year = 2015;
* }
*/
$year = Input::getPost('year', 2015, ['range(1970...2070)']);
public function get(string $key, mixed $default = null, ?array $validation = null): mixed;
public function post(string $key, mixed $default = null, ?array $validation = null): mixed;
Data from reading php://input
.
public function raw(string $key, mixed $default = null, ?array $validation = null): mixed;
Note : Returns the $_FILES
data, normalizing if necessary.
public function files(string $key, mixed $default = null): array|mixed;
$_GET
-> $_POST
public function getPost(string $key, mixed $default = null, ?array $validation = null): mixed;
$_GET
-> php://input
public function getRaw(string $key, mixed $default = null, ?array $validation = null): mixed;
$_GET
-> $_POST
-> php://input
public function getPostRaw(string $key, mixed $default = null, ?array $validation = null): mixed;
$_GET
-> php://input
-> $_POST
public function getRawPost(string $key, mixed $default = null, ?array $validation = null): mixed;
$_POST
-> $_GET
public function postGet(string $key, mixed $default = null, ?array $validation = null): mixed;
$_POST
-> php://input
public function postRaw(string $key, mixed $default = null, ?array $validation = null): mixed;
$_POST
-> $_GET
-> php://input
public function postGetRaw(string $key, mixed $default = null, ?array $validation = null): mixed;
$_POST
-> php://input
-> $_GET
public function postRawGet(string $key, mixed $default = null, ?array $validation = null): mixed;
php://input
-> $_GET
public function rawGet(string $key, mixed $default = null, ?array $validation = null): mixed;
php://input
-> $_POST
public function rawPost(string $key, mixed $default = null, ?array $validation = null): mixed;
php://input
-> $_GET
-> $_POST
public function rawGetPost(string $key, mixed $default = null, ?array $validation = null): mixed;
php://input
-> $_POST
-> $_GET
public function rawPostGet(string $key, mixed $default = null, ?array $validation = null): mixed;
Checks to see if the requested entry has been declared.
It does something like isset($_GET['key'])
, case-insensitively.
public function hasGet(string $key): bool;
It does something like isset($_POST['key'])
, case-insensitively.
public function hasPost(string $key): bool;
Case-insensitively, it queries the body inputs for a key value.
public function hasRaw(string $key): bool;
It does something like isset($_FILES['key'])
, case-insensitively.
public function hasFiles(string $key): bool;
Copyright © 2022 MIT License