Git Product home page Git Product logo

input's Introduction

InitPHP Input

It is a simple library developed to retrieve user inputs by prioritizing or verifying.

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Requirements

Installation

composer require initphp/input

Usage

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)']);

Methods

Input::get()

public function get(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::post()

public function post(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::raw()

Data from reading php://input.

public function raw(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::files()

Note : Returns the $_FILES data, normalizing if necessary.

public function files(string $key, mixed $default = null): array|mixed;

Getting Input with Priority

Input::getPost()

$_GET -> $_POST

public function getPost(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::getRaw()

$_GET -> php://input

public function getRaw(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::getPostRaw()

$_GET -> $_POST -> php://input

public function getPostRaw(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::getRawPost()

$_GET -> php://input -> $_POST

public function getRawPost(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::postGet()

$_POST -> $_GET

public function postGet(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::postRaw()

$_POST -> php://input

public function postRaw(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::postGetRaw()

$_POST -> $_GET -> php://input

public function postGetRaw(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::postRawGet()

$_POST -> php://input -> $_GET

public function postRawGet(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::rawGet()

php://input -> $_GET

public function rawGet(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::rawPost()

php://input -> $_POST

public function rawPost(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::rawGetPost()

php://input -> $_GET -> $_POST

public function rawGetPost(string $key, mixed $default = null, ?array $validation = null): mixed;

Input::rawPostGet()

php://input -> $_POST -> $_GET

public function rawPostGet(string $key, mixed $default = null, ?array $validation = null): mixed;

Has it been declared?

Checks to see if the requested entry has been declared.

Input::hasGet()

It does something like isset($_GET['key']) , case-insensitively.

public function hasGet(string $key): bool;

Input::hasPost()

It does something like isset($_POST['key']) , case-insensitively.

public function hasPost(string $key): bool;

Input::hasRaw()

Case-insensitively, it queries the body inputs for a key value.

public function hasRaw(string $key): bool;

Input::hasFiles()

It does something like isset($_FILES['key']) , case-insensitively.

public function hasFiles(string $key): bool;

Credits

License

Copyright © 2022 MIT License

input's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.