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
Solved

grab details about server and page

Posted on 2006-11-16
6
193 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
  • 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

840 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