forumnz Posted February 6, 2008 Share Posted February 6, 2008 How can I echo the page URL? For example: http://www.phpfreaks.com/ If that was the URL, how could I echo that in PHP? Thanks, Sam. Quote Link to comment https://forums.phpfreaks.com/topic/89773-the-page-name/ Share on other sites More sharing options...
wildteen88 Posted February 6, 2008 Share Posted February 6, 2008 To get the hostname (phpfreaks.com) you'd use $_SERVER['SERVER_NAME'] so the following script will output the sites url: <?php echo 'http://www.' . $_SERVER['SERVER_NAME']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/89773-the-page-name/#findComment-460021 Share on other sites More sharing options...
phorcon3 Posted February 6, 2008 Share Posted February 6, 2008 <?php $domain = $_SERVER['SERVER_NAME']; $page = $_SERVER['REQUEST_URI']; echo 'http://'.$domain.$page; ?> i dunno how else to do it.. Quote Link to comment https://forums.phpfreaks.com/topic/89773-the-page-name/#findComment-460024 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.