Uri class for handling links.

Similar to CMain::GetCurPageParam and DeleteParam in the old code. Handling the class \Bitrix\Main\Web\Uri is more complex than in the old core due to every method in this class being responsible only for a single aspect of class operation.

Method Description Available from version
addParams Adds parameters into the request pr replaces existing parameters.
deleteParams Deletes parameters from request.
getFragment Returns a fragment.
getHost Returns a host.
getLocator Returns URL without a fragment.
getPass Returns a password.
getPath Returns a path.
getPathQuery Returns path with request.
getPort Returns port number.
getQuery Returns a request.
getScheme Returns a layout.
getUri Returns URL with fragment, if available.
getUser Returns a user.
setHost Sets a host.
setPath Sets a path.
setUser Sets a user.
setPass Sets a password.


use Bitrix\Main\Application;
use Bitrix\Main\Web\Uri;

$request = Application::getInstance()->getContext()->getRequest();
$uriString = $request->getRequestUri();
$uri = new Uri($uriString);
$uri->addParams(array("foo" => "bar"));
$redirect = $uri->getUri(); 

© «Bitrix24», 2001-2023