PHP code example of mtchabok / request

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

    

mtchabok / request example snippets


use \Mtchabok\Request\Request;

$request = Request::newRequest(Request::METHOD_CLI);
$request = Request::newRequestGlobal(['method'=>Request::METHOD_GET]);

use \Mtchabok\Request\Request;
$request = Request::newRequest();
$request->server->HTTP_HOST;
$request->server->getString('REMOTE_ADDR', '127.0.0.1');
$request->server['REQUEST_TIME'];

use \Mtchabok\Request\Request;
$request = Request::newRequest();
$request->query->foo; // string
$request->query->getNumber('id', 12); // numeric: int or float
$request->query['page']; // string

use \Mtchabok\Request\Request;
$request = Request::newRequest();
$request->post->first_name;
$request->post->getString('last_name', null, ' -'); // return (string) (isset($_POST['last_name']) ?trim($_POST['last_name'], ' -') :null);
$request->post['mobile'];

use \Mtchabok\Request\Request;
$request = Request::newRequest();
$request->post->country = 'Iran';
$request->post->set('city', 'Tehran');
$request->get['postal_code'] = '1234567890';

use \Mtchabok\Request\Request;
$request = Request::newRequest();
$request->query->delete('postal_code');
unset($request->post->city);
unset($request->post['country']);