Documentation

HttpRequest

HttpRequest class manages Request object, containing information on current request - its type, parameters and their values: "server query" class. Class allows removing global variables within code, used in the old core.

Method Description Available from version
Constructor Creates new object HttpRequest.
addFilter Applies filter to request data with preservation of original values.
getCookie Returns COOKIES parameters from current request.
getCookieList Returns list of COOKIES parameters for current request.
getHttpHost Returns server variable node without port number.
getPost Returns POST parameters for curreте request.
getPostList Returns list of POST parameters for current request.
getQuery Returns GET parameter for current request.
getQueryList Returns list of GET parameters for current request.
getRequestedPage Returns current page, retrieved from requested URL.
getScriptFile Returns script file, edited by urlrewrite.php if required, or returns the file virtual_file_system.php.
getSystemParameters Returns array with predefined request parameters.
getUserAgent Returns requested title for HTTP user agent.
getDecodedUri Returns decoded URL.
getFile Returns FILES parameters for current request.
getFileList Returns list of FILES parameters for the current request.
getInput Returns initial requested data.

Example

Developer doesn't need to construct the object, it can be retrieved via the application and context:

use Bitrix\Main\Application;
$request = Application::getInstance()->getContext()->getRequest();

$name = $request->getPost("name");
$email = htmlspecialchars($request->getQuery("email")); 


© «Bitrix24», 2001-2024
Up