Page 1 of 1

*sigh* Super noob has a question :)

Posted: Thu Jan 22, 2004 5:13 pm
by hurdy gurdy
I've looked everywhere, and I'm kicking myself constantly over this, but how does one get the URL of a page and pass it to a variable as a string?

or

Would I get the current pages URL bu using something like this:

Code: Select all

$url = $_SERVER['REQUEST_URI'];
or would this be better?

Code: Select all

$url = $_SERVER['PHP_SELF'];
essentially, what I want to do is pass the URL as a string to a variable, so that

$url = "http://www.someplace.com/somepage.php";

did any of that make sense? :)

Thanks in advance

Posted: Thu Jan 22, 2004 5:40 pm
by Crashin
Are you trying to get the URL of the page that you are on? I'm not sure where your URL is coming from...

Posted: Thu Jan 22, 2004 6:07 pm
by DuFF
For a link you are better off using

Code: Select all

$url = $_SERVER['REQUEST_URI'];
. This will give you the full URL along with any arguments passed (like file.php?id=12)

Using

Code: Select all

$_SERVER['PHP_SELF'];
will only give the filename relative to the document root, so something like: public_HTML/mystuff/files/thisfile.php

Posted: Thu Jan 22, 2004 6:59 pm
by hurdy gurdy
ah excellent!

muchas gracias!