Created
July 10, 2014 08:31
-
-
Save ovcharenkovv/fe9d4d3b228de0df719e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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