Sunday, July 18, 2010

Simple $_GET and $_POST request manager

This is a really simple but extremally useful class/function.
Esta é uma função muito simples porém extremamente útil.

class Request{
  public static function getParam($name,$default = null) {
        return isset($_GET[$name]) ? $_GET[$name] : (isset($_POST[$name]) ? $_POST[$name] : $default);
    }
}

//mode of use - como usar
$var = Request::getParam('name','defaultValue');

No comments:

Post a Comment