getting the basic url

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
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

getting the basic url

Post by pelegk2 »

i have this url :

Code: Select all

<?php
http://localhost/uniprod/index.php?cont=WeightStations
?>
and i want to know only :

Code: Select all

<?php
http://localhost/uniprod/index.php
?>
how do i do that?
thnaks in advance
peleg
crookedgoomba
Forum Newbie
Posts: 4
Joined: Fri May 28, 2004 2:38 am

Post by crookedgoomba »

how about:

Code: Select all

preg_match("/(.*)\?/","http://localhost/uniprod/index.php?cont=WeightStations",$boo);
echo $boo[1];
Last edited by crookedgoomba on Fri May 28, 2004 3:02 am, edited 1 time in total.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

what about this

Code: Select all

$url = parse_url ( "http://localhost/uniprod/index.php?cont=WeightStations" );

echo $url['sheme'].$url['host'].$url['path'];
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

thnaks alot both of u:)
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

ow 1 sec!!!
how can i get the full url :
"http://localhost/uniprod/index.php?cont=WeightStations"
on the server side?withought adding $_SERVER['PHP_SELF'] to another variable and so on?
crookedgoomba
Forum Newbie
Posts: 4
Joined: Fri May 28, 2004 2:38 am

Post by crookedgoomba »

ummmm

Code: Select all

echo $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
maybe?!
Post Reply