How to get the full URL of a Drupal page?

In Drupal, you can use the url() function to get the full URL of a page. For example, if you want to get the full URL of the current page, you can use the following code:

<?php

$current_url = url('<current>', ['absolute' => true]);

Watch a course Learn object oriented PHP

You can also use the url() function to get the URL of a specific page by passing in the path of the page as the first argument. For example, if you want to get the URL of the "about" page, you can use the following code:

<?php

$about_url = url('about', ['absolute' => true]);

The absolute option set to TRUE will return an absolute URL, if you set it to false it will return a relative URL.