r::method PHP Method

method() static public method

Returns the current request method
static public method ( ) : string
return string POST, GET, DELETE, PUT
    static function method()
    {
        return strtoupper(server::get('request_method'));
    }

Usage Example

示例#1
0
 function map()
 {
     $url = url::strip_query(server::get('request_uri'));
     $url = str_replace(rtrim(c::get('router.root'), '/'), '', $url);
     $method = r::method();
     foreach (self::$routes as $key => $route) {
         if (!in_array($method, $route['methods'])) {
             continue;
         }
         $key = str_replace(')', ')?', $key);
         $args = array();
         $regex = preg_replace_callback('#@([\\w]+)(:([^/\\(\\)]*))?#', function ($matches) use(&$args) {
             $args[$matches[1]] = null;
             if (isset($matches[3])) {
                 return '(?P<' . $matches[1] . '>' . $matches[3] . ')';
             }
             return '(?P<' . $matches[1] . '>[^/\\?]+)';
         }, $key);
         if (preg_match('#^' . $regex . '(?:\\?.*)?$#i', $url, $matches)) {
             foreach ($args as $k => $v) {
                 self::$params[$k] = array_key_exists($k, $matches) ? urldecode($matches[$k]) : null;
             }
             return $route['callback'];
         }
     }
     return false;
 }
All Usage Examples Of r::method