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. 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']; ?> 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.. Link to comment https://forums.phpfreaks.com/topic/89773-the-page-name/#findComment-460024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.