Returns the requested URI (path and query string).
public getRequestUri ( ) : string | ||
return | string | The raw URI (i.e. not URI decoded) |
use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $uri = $request->getRequestUri(); echo $uri; // outputs, for example, "/my-page?foo=bar"
use Symfony\Component\HttpFoundation\Request; $request = Request::create('/my-page', 'GET', ['foo' => 'bar']); $uri = $request->getRequestUri(); echo $uri; // outputs "/my-page?foo=bar"In this example, we manually create a Request object for the "/my-page" page using the create method, and pass in some query parameters as the third argument. We then get the request URI and output it to the browser. This method is part of the Symfony HttpFoundation package library, which provides various classes for handling HTTP requests and responses in PHP.
public getRequestUri ( ) : string | ||
return | string | The raw URI (i.e. not URI decoded) |