[SOLVED] how to tell if user has went to root site?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

[SOLVED] how to tell if user has went to root site?

Post by stevestark5000 »

i got a cms that i am working on. i need to tell is a user has went to the root of a website, where a website can be any website. if example.com will not be good enought as i need to tell if the script is at any site. the code need to be in an if statement. for example. if (site at root) { }
Last edited by stevestark5000 on Sat Mar 12, 2011 1:25 am, edited 1 time in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: how to tell if user has went to root site?

Post by Christopher »

Use phpinfo() to look at the $_SERVER superglobal array. There are many values there that will be useful to you.
(#10850)
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: how to tell if user has went to root site?

Post by stevestark5000 »

can i have an example please?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: how to tell if user has went to root site?

Post by Christopher »

(#10850)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: how to tell if user has went to root site?

Post by John Cartwright »

Another way to look at what the $_SERVER superglobal has available would be to

Code: Select all

echo '<pre>'. print_r($_SERVER, true) .'</pre>';
which essentially gives you the same info as phpinfo() would.
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: how to tell if user has went to root site?

Post by stevestark5000 »

solved. thank you.
Post Reply