Solved

grab details about server and page

Posted on 2006-11-16
6
201 Views
Last Modified: 2006-11-18
Hi

I have url's like the following and I want to break them into bits to then make links/labels etc

What do I need to grab ALL the details from a URL made like this

http://s1234:7777/webapp/eforms/abandoned-vehicles.php
IE Address / port / path / current page

Thanks
Neil
0
Comment
Question by:Neil Thompson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 13

Expert Comment

by:rhickmott
ID: 17961287
http://uk2.php.net/manual/en/function.parse-url.php

<?php
$url = 'http://username:password@hostname/path?arg=value#anchor';

print_r(parse_url($url));

echo parse_url($url, PHP_URL_PATH);
?>  

The above example will output:

Array
(
    [scheme] => http
    [host] => hostname
    [user] => username
    [pass] => password
    [path] => /path
    [query] => arg=value
    [fragment] => anchor
)
0
 
LVL 13

Expert Comment

by:rhickmott
ID: 17961297
Above will output

scheme - e.g. http
host
port
user
pass
path
query - after the question mark ?
fragment - after the hashmark #
0
 
LVL 3

Author Comment

by:Neil Thompson
ID: 17963330
superb, many thanks!
Neil
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:Neil Thompson
ID: 17963389
sorry

just realised that doesn't actually grab the current full url first, any ideas how to get that?

neil
0
 
LVL 13

Accepted Solution

by:
rhickmott earned 500 total points
ID: 17963660
Well that's a lore more difficult unfortunately.

You can normally get the full page request by using something along the lines of.

$_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; But I don't think that will include any port usage etc.

You could use a combination of

$_SERVER['SERVER_PROTOCOL'];
$_SERVER['HTTP_HOST'];
$_SERVER['SERVER_PORT'];
$_SERVER['REQUEST_URI'];

Maybe something along the lines of

"http://" . $_SERVER['HTTP_HOST'] . ":" . $_SERVER['SERVER_PORT'] . "/" . $SERVER['REQUEST_URI'];
0
 
LVL 3

Author Comment

by:Neil Thompson
ID: 17963689
excellent, thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question