Solved

grab details about server and page

Posted on 2006-11-16
6
206 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
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

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!

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses how to create an extensible mechanism for linked drop downs.
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 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