Page 1 of 1

Get domain

Posted: Sat Jun 04, 2005 10:25 am
by S_henry
In php, how can we get the domain name? For example, if i put/run my system in the domain server called http://www.abc.com/, what is the code to get that domain name server (http://www.abc.com/)? Anybody can help me pls?

Posted: Sat Jun 04, 2005 10:33 am
by m3mn0n
Run this snippet:

Code: Select all

<?php
  echo '<pre>';
    print_r ($_SERVER);
  echo '</pre>';
?>
To extract the exact domain, check out a function like ereg()

Posted: Sat Jun 04, 2005 10:36 am
by lazersam
$referred_from = $HTTP_REFERER; Should get the address the visitor came from.

Posted: Sat Jun 04, 2005 10:37 am
by m3mn0n
lazersam wrote:$referred_from = $HTTP_REFERER; Should get the address the visitor came from.
Don't rely on that too much. Some browsers do not send that variable and it can be easily spoofed.

Posted: Sat Jun 04, 2005 11:21 am
by S_henry
OK. Perfect. Thanx guys.. :D