Documentation

Request

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.

Example

$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")


© «Bitrix24», 2001-2024
Up