Solved

grab details about server and page

Posted on 2006-11-16
6
186 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Checking CSRF token within a function 36 76
How to init a part of Javascript based on PHP value for Datatables & Yadcf 8 48
PHP AJAX Wordpress 9 21
PHP AJAX JSON 2 61
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
The viewer will learn how to count occurrences of each item in an array.

810 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