Forum Moderators: coopster

Message Too Old, No Replies

Getting actual site address using php

I need to find out what the exact URL of the page the user has requested is

         

willg825

12:15 am on Sep 9, 2003 (gmt 0)

10+ Year Member



Hi - I need to run a script that includes a different file depending on whether the user is at "index.php" or "home.php" - how would I check? Is there a variable (I couldnt find one) that holds the filename the user has requested?

Thanks in advance-

will

san_garrafa

12:19 am on Sep 9, 2003 (gmt 0)

10+ Year Member



$_SERVER[SCRIPT_NAME]
or
$_SERVER[PHP_SELF]

san_garrafa

12:32 am on Sep 9, 2003 (gmt 0)

10+ Year Member



But there is a difference between them for example:
calling yourwebsite.com/index.php/whatever/whateverelse
asuming index.php is the script we are talking about.

$_SERVER[SCRIPT_NAME] is /index.php/whatever/whateverelse
and
$_SERVER[PHP_SELF] is /index.php

Hope this helps.

San Garrafa

willg825

12:53 am on Sep 9, 2003 (gmt 0)

10+ Year Member



Just to make sure I got it right--

if ($_SERVER[PHP_SELF] == "/index.php")
{ whatever }
else { etc}

would that be right?

san_garrafa

2:20 pm on Sep 9, 2003 (gmt 0)

10+ Year Member



Yes. That's right.

San Garrafa