PHP code example of lisennk / request

1. Go to this page and download the library: Download lisennk/request 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/ */

    

lisennk / request example snippets


echo Request::input('name'); // outputs "Alice"



use Lisennk\Request;

$request = Request::instance();
echo $request->input('name'); // outputs "Alice"

echo $request->name; // outputs "Alice"

echo Request::input('name'); // outputs "Alice"

echo Request::input('name', 'Unknown Name'); // outputs "Unknown Name" if "name" doesnt passed
echo $request->input('name', 'Unknown Name'); // the same same, outputs "Unknown Name" if "name" doesnt passed

if (Request::has('name')) echo 'Name passed!'; // outputs "Name passed!" if there is value with "name" key

if ($request->has('name', 'Alice')) echo 'The name is Alice!'; // outputs "the name is Alice"
if (Request::has('name', 'Bob')) echo 'Bob is here!'; // we know that name is "Alice", not "Bob", so here we will not get any output

if ($request->notEmpty()) echo 'There is something to work with!';