Want create site? Find Free WordPress Themes and plugins.

In this code snippet, I’ll show you how easy it is to get current page url in php. This is a PHP function to get the current page URL with only PHP. This works within WordPress, as well.

The Code Snippet:

/**
 * Get current page url
 */
function isa_current_url() {
        $pageURL = 'http';
        if( isset($_SERVER["HTTPS"]) ) {
            if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
        }
        $pageURL .= "://";
        if ($_SERVER["SERVER_PORT"] != "80") {
            $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
        } else {
            $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
        }
        return $pageURL;
}

Now enjoy!..

Did you find apk for android? You can find new Free Android Games and apps.
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Posted by Editorial Staff