You have a PHP script and you need to get the URL of the current page. How would you do this using the $_SERVER superglobal?

  • $_SERVER['REQUEST_URI']
  • $_SERVER['CURRENT_URL']
  • $_SERVER['PAGE_URL']
  • $_SERVER['SITE_URL']
To retrieve the URL of the current page using the $_SERVER superglobal in PHP, you can use $_SERVER['REQUEST_URI']. This key contains the path and query string of the requested URL. It provides the information needed to reconstruct the URL of the current page. By accessing the 'REQUEST_URI' key within the $_SERVER superglobal, you can obtain the URL of the current page. Learn more: https://www.php.net/manual/en/reserved.variables.server.php
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *