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
Loading...
Related Quiz
- What is the purpose of the array_combine() function in PHP?
- The preg_match() function in PHP returns true if the pattern was found in the string and false otherwise.
- The $_SERVER superglobal in PHP is an associative array.
- In PHP, which keyword is used to define a constant?
- What kind of operations can be performed inside a constructor in a PHP class?