Get current page url in php

In an application, sometimes we need to get the current page URL in php. I mean, the URL shown in the browser. Here is how you can do it. First, we will declare and use the function as the following: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php function current_page_url() { $url = 'http'; if ($_SERVER["HTTPS"] == "on") $url .= "s"; $url .= "://"; if ($_SERVER["SERVER_PORT"] != "80") […]

Continue Reading

You may also like