URL commands

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
swartbees
Forum Newbie
Posts: 5
Joined: Wed Mar 31, 2004 9:59 am

URL commands

Post by swartbees »

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://&#123;$_SERVER&#1111;'HTTP_HOST']&#125;&#123;$_SERVER&#1111;'PHP_SELF']&#125;?&#123;$_SERVER&#1111;'QUERY_STRING']&#125;";

$urlArray = parse_url($urlString); 
echo "User: " . $urlArray&#1111;"user"] . "<br>"; 
echo "Password: " . $urlArray&#1111;"pass"] . "<br>"; 
echo "Domain: " . $urlArray&#1111;"host"] . "<br>"; 
echo "Query String: " . $urlArray&#1111;"query"] . "<br>"; 
echo "Fragment: " . $urlArray&#1111;"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 »

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 »

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,
Post Reply