The base URL never ends with a /.
This is similar to getBasePath(), except that it also includes the
script filename (e.g. index.php) if one exists.
public getBaseUrl ( ) : string | ||
return | string | The raw URL (i.e. not urldecoded) |
use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $baseUrl = $request->getBaseUrl(); echo 'Base URL: ' . $baseUrl;
Base URL: https://example.com/myapp/The package library for this method is Symphony\Component\HttpFoundation.
public getBaseUrl ( ) : string | ||
return | string | The raw URL (i.e. not urldecoded) |