PHP code example of sivka / request
1. Go to this page and download the library: Download sivka/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/ */
sivka / request example snippets
// $_POST = ['id' => 1, 'name' => 'Valera']
use Sivka\Request;
echo Request::post('name'); // Valera
$post = Request::post();
echo $post->name; // Valera
echo $post->not_defined_var; // NULL
Request::get(); // $_GET
Request::post(); // $_POST
Request::files(); // $_FILES
Request::session(); // $_SESSION
Request::cookie(); // $_COOKIE
Request::server(); // $_SERVER
Request::headers(); // http headers
$post = Request::post();
$post->set('id', 2);
// or directly
$post->id = 2;
// array maybe used
$newData = ['surname' => 'Smith', 'age' => 33];
$post->set($newData);
echo $post->int('id'); // 2
echo $post->string('id'); // '2'
echo $post->get('id'); // 2
// or simply
echo $post->id; // 2
echo $post->get('notDefined', 'define_me'); // define_me
$post->count();
$post->toJson();
$post->toArray();
$post->delete('id');
echo $post->has('name'); // true
$post->keys();
$id = isset($_POST['id']) ? (int)$_POST['id'] : 0;