Request abstract class. Request object allows getting data on the current request/query: method and protocol, requested URL, passed parameters and etc. Extension to class \Bitrix\Main\Type\ParameterDictionary.

Queries the following namespace:

Method Description Available from version
isAjaxRequest Returns true when current class is AJAX.


$request = $context->getRequest();
// Or more abridged format:
$request = Context::getCurrent()->getRequest();

Request parameters:

$value = $request->get("param");       // getting GET or POST parameter
$value = $request["param"];            // gets GET or POST parameter
$value = $request->getQuery("param");  // gets GET-parameter
$values = $request->getQueryList();    // gets list of GET parameters
$value = $request->getPost("param");   // gets POST parameter
$values = $request->getPostList();     // gets list of POST parameters
$value = $request->getFile("param");   // gets uploaded file
$values = $request->getFileList();     // gets list of uploaded files
$value = $request->getCookie("param"); // gets cookie value
$values = $request->getCookieList();   // gets list of cookies

Request data:

$method = $request->getRequestMethod(); // gets a request method
$flag = $request->isGet();              // true - GET query, otherwise false
$flag = $request->isPost();             // true - POST query, otherwise false
$flag = $request->isAjaxRequest();      // true - AJAX query, otherwise false
$flag = $request->isHttps();            // true - HTTPS query, otherwise false

Data on requested page:

$flag = $request->isAdminSection();            // true - located in control panel, otherwise false
$requestUri = $request->getRequestUri();       // Requested address (for example "/catalog/category/?param=value")
$requestPage = $request->getRequestedPage();   // Requested page (for example "/catalog/category/index.php")
$rDir  = $request->getRequestedPageDirectory();// Requested page directory (for example "/catalog/category")

User Comments

User comments are not part of official documentation. Use information provided by other users in the comments at your own risk.

The User Comments section is not to be used as a feature discussion board. Only registered users can post comments. Your comment will be visible once it has been approved by the moderator.
© «Bitrix24», 2001-2022