PHP code example of initphp / input
1. Go to this page and download the library: Download initphp/input library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
initphp / input example snippets
use \InitPHP\Input\Facade\Inputs as Input;
// echo isset($_GET['name']) ? $_GET['name'] : 'John';
echo Input::get('name', 'John');
use \InitPHP\Input\Facade\Inputs as 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)']);
use \InitPHP\Input\Facade\Inputs as Input;
/**
* if(isset($_POST['password']) && isset($_POST['password_retype']) && !empty($_POST['password']) && $_POST['password'] == $_POST['password_retype']){
* $password = $_POST['password'];
* }else{
* $password = null;
* }
*/
$password = Input::post('password', null, ['
public function get(string $key, mixed $default = null, ?array $validation = null): mixed;
public function post(string $key, mixed $default = null, ?array $validation = null): mixed;
public function raw(string $key, mixed $default = null, ?array $validation = null): mixed;
public function getPost(string $key, mixed $default = null, ?array $validation = null): mixed;
public function getRaw(string $key, mixed $default = null, ?array $validation = null): mixed;
public function getPostRaw(string $key, mixed $default = null, ?array $validation = null): mixed;
public function getRawPost(string $key, mixed $default = null, ?array $validation = null): mixed;
public function postGet(string $key, mixed $default = null, ?array $validation = null): mixed;
public function postRaw(string $key, mixed $default = null, ?array $validation = null): mixed;
public function postGetRaw(string $key, mixed $default = null, ?array $validation = null): mixed;
public function postRawGet(string $key, mixed $default = null, ?array $validation = null): mixed;
public function rawGet(string $key, mixed $default = null, ?array $validation = null): mixed;
public function rawPost(string $key, mixed $default = null, ?array $validation = null): mixed;
public function rawGetPost(string $key, mixed $default = null, ?array $validation = null): mixed;
public function rawPostGet(string $key, mixed $default = null, ?array $validation = null): mixed;
public function hasGet(string $key): bool;
public function hasPost(string $key): bool;
public function hasRaw(string $key): bool;