PHP Snippets
Get The Current Page URL

This function returns the current page URL. It concatenates the server’s host name and the request URI from PHP’s superglobal $_SERVER array. This function is useful for generating links to the current page, or for logging or debugging purposes.
PHP Function:
function getCurrentPageURL() { return 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; }
// Example
// echo getCurrentPageURL();
Back to Home
Share:
Comments
Share your thoughts and join the conversation
No comments yet
Be the first to share your thoughts!
Failed to load comments
Please try refreshing the page
Leave a Comment