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;

// GET /?name=Jane
// echo isset($_GET['name']) ? $_GET['name'] : 'John';
echo Input::get('name', 'John'); // 'Jane'

use InitPHP\Input\Inputs;

$input = new Inputs(); // reads $_GET, $_POST and php://input

$name = $input->get('name', 'John');

$input = new Inputs(
    get: ['name' => 'Jane'],
    post: ['email' => '[email protected]'],
    raw: ['token' => 'abc123'],
);

$input->get('name', 'guest');   // from $_GET
$input->post('email');          // from $_POST
$input->raw('token');           // from the JSON request body

// GET /?year=1999  (no POST, no body)
$input->getPost('year', 2015); // 1999 — taken from $_GET

// POST year=1999  (no GET)
$input->getPost('year', 2015); // 1999 — fell through to $_POST

// if year is present and within 1970–2070 use it, otherwise 2015
$year = $input->getPost('year', 2015, ['range(1970...2070)']);

// 

$input->hasGet('name');  // isset($_GET['name']) — case-sensitive
$input->hasPost('email');
$input->hasRaw('token');