PHP code example of goenitz / request

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

    

goenitz / request example snippets


$email = isset($_POST['email']) ? $_POST['email'] : '';
$email = trim($email);
if ($email == '') {
    //do sth
}

$request = new \Goenitz\Request\Request();

$email = $request->post->email;
if (is_null($email)) {
    //do sth
}

//or
$email = $request->post['email'];

//or
$email = $request->post('email');

//or set a default value
$email = $request->post('email', '[email protected]');

//or get all post data as an array.
$post = $request->post->toArray();

$page = $request->get->page;
$ip = $request->server->REMOTE_ADDR
// etc.

$ip = $request->ip();

$files = $request->files->toArray();

$file = $request->files->file;
//or
$file = $request->files('file');
//or
$file = $request->files['file'];

$file->getOriginalFileName();  // "32fa828ba61ea8d33395a581970a304e241f5884.gif"
$file->getOriginalExtension(); // "gif"
$file->getTempName();          // "C:\Users\tianyi\AppData\Local\Temp\php363C.tmp"
$file->getType();              // "image/gif"
$file->getError();             // 0
$file->save('./1.gif');        // true

$request = new \Goenitz\Request\Request(false, false);