Page 1 of 1

URL commands

Posted: Thu Jun 03, 2004 6:05 am
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

Posted: Thu Jun 03, 2004 1:08 pm
by Guilherme Blanco
Apply a RegExp in the $_SERVER['HTTP_HOST'] and you'll take the data.

Regards,

Posted: Fri Jun 04, 2004 3:59 am
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,