How to get Current URL in PHP
Submitted by nurhodelta_17 on Tuesday, February 20, 2018 - 19:38.
Full Code
Here's the full code that you can use:- $URL = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
Definitions
Here's the definitions for the above code.- $protocol checks if the current path contains http or https protocol
- $_SERVER['HTTP_HOST'] as per manual definition is the contents of the Host: header from the current request.
- $_SERVER['REQUEST_URI'] gets the full path of the page.