webref.eu Posted December 13, 2008 Share Posted December 13, 2008 If I am on page: http://www.mysite.co.uk/show-review.php and I want the script to read the domain of the site, i.e. just the: http://www.mysite.co.uk what can I use to get this? Thanks all. Link to comment https://forums.phpfreaks.com/topic/136831-obtain-site-url/ Share on other sites More sharing options...
T Horton Posted December 13, 2008 Share Posted December 13, 2008 Hi Does this help? <?php $domain = $_SERVER['HTTP_HOST']; ?> Tom Link to comment https://forums.phpfreaks.com/topic/136831-obtain-site-url/#findComment-714605 Share on other sites More sharing options...
webref.eu Posted December 15, 2008 Author Share Posted December 15, 2008 Yes, thank you. Rgds Link to comment https://forums.phpfreaks.com/topic/136831-obtain-site-url/#findComment-715808 Share on other sites More sharing options...
webref.eu Posted January 7, 2009 Author Share Posted January 7, 2009 If I use this code on say: http://www.mysite.co.uk/show-review.php Then $domain will return as: www.mysite.co.uk What technique should be used ??? if you just want to return: mysite.co.uk Many thanks Link to comment https://forums.phpfreaks.com/topic/136831-obtain-site-url/#findComment-731802 Share on other sites More sharing options...
Clinton Posted January 7, 2009 Share Posted January 7, 2009 Hmmm.... I know this one I just don't know how to answer it. I know there's like a substring or string something where you can edit the results and take out the http://.... let me see if I can find it.... Link to comment https://forums.phpfreaks.com/topic/136831-obtain-site-url/#findComment-731809 Share on other sites More sharing options...
Clinton Posted January 7, 2009 Share Posted January 7, 2009 $rest = substr("abcdef", 2, -1); // returns "cde" So.... try... $domain = substr("$domain", 7, 0); // The "" May not be right because it's a variable so you might have to change it to '' or none at all depending on its use but give that a shot. http://us3.php.net/manual/en/function.substr.php Link to comment https://forums.phpfreaks.com/topic/136831-obtain-site-url/#findComment-731819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.