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
swartbees
Forum Newbie
Posts: 5 Joined: Wed Mar 31, 2004 9:59 am
Post
by swartbees » Thu Jun 03, 2004 6:05 am
Hi there
I want to get the full URL details of the current page with parse_url.
Currently I do the following:
Code: Select all
<?Php
$urlString = "http://{$_SERVERї'HTTP_HOST']}{$_SERVERї'PHP_SELF']}?{$_SERVERї'QUERY_STRING']}";
$urlArray = parse_url($urlString);
echo "User: " . $urlArrayї"user"] . "<br>";
echo "Password: " . $urlArrayї"pass"] . "<br>";
echo "Domain: " . $urlArrayї"host"] . "<br>";
echo "Query String: " . $urlArrayї"query"] . "<br>";
echo "Fragment: " . $urlArrayї"fragment"] . "<br>";
?>
Which outputs:
User:
Password:
Domain:
http://www.mydomain.com
Query String: id=1234
Fragment:
How can I add the Username, password and Fragment parts to $urlString
if my url is of the form:
http://username:password@www.mydomain.c ... sting%this
??
Regards
swartbees
Guilherme Blanco
Forum Newbie
Posts: 12 Joined: Wed Jun 02, 2004 4:58 pm
Location: São Carlos - SP/Brazil
Contact:
Post
by Guilherme Blanco » Thu Jun 03, 2004 1:08 pm
Apply a RegExp in the $_SERVER['HTTP_HOST'] and you'll take the data.
Regards,
swartbees
Forum Newbie
Posts: 5 Joined: Wed Mar 31, 2004 9:59 am
Post
by swartbees » Fri Jun 04, 2004 3:59 am
How will I go about doing that? When I echo $_SERVER['HTTP_HOST'] I only get
http://www.mydomain.com and no other data?
Regards,