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
kkonline
Forum Contributor
Posts: 251 Joined: Thu Aug 16, 2007 12:54 am
Post
by kkonline » Sun Sep 02, 2007 6:52 am
I want to store the current page url in variable $link
I used
But it gave me
only pages.php if the current link is
http://localhost/pages.php?catid=1&id=3
This is required as i am storing the url in a social bookmarking site
What to do?
Ballam
Forum Newbie
Posts: 4 Joined: Sun Sep 02, 2007 7:32 am
Post
by Ballam » Sun Sep 02, 2007 7:34 am
I was actually doing the same thing yesterday, but for a different reason!
To get the full url you're best doing this:
$variable = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
Hope this helps
B
kkonline
Forum Contributor
Posts: 251 Joined: Thu Aug 16, 2007 12:54 am
Post
by kkonline » Sun Sep 02, 2007 7:43 am
Ballam wrote: I was actually doing the same thing yesterday, but for a different reason!
To get the full url you're best doing this:
$variable = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
Hope this helps
B
It works if i use
Code: Select all
$link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
I am wondering what should i write if there are some sub directories
http://localhost/article/pages.php?page=1&catid=1
will the above code still work???
Ballam
Forum Newbie
Posts: 4 Joined: Sun Sep 02, 2007 7:32 am
Post
by Ballam » Sun Sep 02, 2007 7:48 am
yeah that should work fine
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Sep 02, 2007 7:59 am
There are a lot of other things you need to be concerned with regarding the rebuilding of the current URL.
viewtopic.php?t=37950&highlight=geturl