Skip to content

Instantly share code, notes, and snippets.

@ovcharenkovv
Created July 10, 2014 08:31
Show Gist options
  • Save ovcharenkovv/fe9d4d3b228de0df719e to your computer and use it in GitHub Desktop.
Save ovcharenkovv/fe9d4d3b228de0df719e to your computer and use it in GitHub Desktop.
<?php
class Request
{
static function getVar($name, $type = false){
$types = array( "bool","int","float", "string", "array", "object", "null" );
if (isset ($_REQUEST[$name])) {
$param = $_REQUEST[$name];
if ( in_array($type, $types)) {
settype($param, $type);
}
return $param;
} else {
return null;
}
}
static function isPost (){
return ($_SERVER['REQUEST_METHOD'] == 'POST')? true: false;
}
static function isGet (){
return ($_SERVER['REQUEST_METHOD'] == 'GET')? true: false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment