How to get Base Url and Current Url Magento 2?

In Magento 2, You can get Base Url, Current Url, get Media URL, get static page URL and custom URL using Magento\Store\Model\StoreManagerInterface and Magento\Framework\UrlInterface Object.

Using StoreManager Object,
Create PHP file and Passed Dependency injection Magento\Store\Model\StoreManagerInterface,

Call in Template file,

URL Using UrlInterface Object in Plugin and Observer file,

Call In template file,

You can add a Query parameter in URL,
// You can set query parameter using
$url = $this->urlBuilder->setQueryParam(‘query1’, ‘value1’);

if you want to pass multiple query parameter you need to call again above line,

echo $block->getQueryParameter();