码迷,mamicode.com
首页 > 其他好文 > 详细

Request

时间:2016-07-05 12:00:19      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

Request

The Request class provides many methods for examining the HTTP request for your application and extends the Symfony\Component\HttpFoundation\Request class.

Please note that both Input and Request do NOT sanitize your data, it is up to you to do that.

Retrieving The Request URI

$uri = Request::path();

Retrieving The Request Method

$method = Request::method();

if (Request::isMethod(‘post‘))
{
    //
}

Determine If The Request Path Matches A Pattern

if (Request::is(‘admin/*‘))
{
    //
}

Get The Request URL

$url = Request::url();

Retrieve A Request URI Segment

$segment = Request::segment(1);

Retrieving A Request Header

$value = Request::header(‘Content-Type‘);

Retrieving Values From $_SERVER

$value = Request::server(‘PATH_INFO‘);

Determine If The Request Is Over HTTPS

if (Request::secure())
{
    //
}

Determine If The Request Is Using AJAX

if (Request::ajax())
{
    //
}

Determine If The Request Has JSON Content Type

if (Request::isJson())
{
    //
}

Determine If The Request Is Asking For JSON

if (Request::wantsJson())
{
    //
}

Checking The Requested Response Format

The Request::format method will return the requested response format based on the HTTP Accept header:

if (Request::format() == ‘json‘)
{
    //
}

Request

标签:

原文地址:http://www.cnblogs.com/chunguang/p/5643008.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!