The HTTP_URL class is something I quickly hacked together a while ago. It reads a URL and returns and parses the HTTP header and body for various things.
The easiest way to explain is by example:
< php
require 'HTTP_URL.php';
$url = new HTTP_URL('http://viebrock.ca/');
$url->get();
print_r($url->headers);
$url->parseBody();
print_r($url->refs);
>
The output:
Array ( [_Request-Protocol] => HTTP/1.1 [_Request-Code] => 200 [_Request-String] => OK [Date] => Mon, 12 Apr 2004 20:32:09 GMT [Server] => Apache [X-Powered-By] => PHP/4.3.0 [Transfer-Encoding] => chunked [Content-Type] => text/html [_Date] => 1081801929 ) Array ( [frame] => Array ( ) [img] => Array ( [0] => /images/3t.jpg [1] => http://viebrock.ca/albums/Natalie/IMG_1015.thumb.jpg ) [a] => Array ( [0] => / [1] => /?parentid=4 [2] => /?parentid=5 [3] => /?parentid=7 [4] => /?parentid=8 [5] => /?parentid=9 [6] => /?rss=1 [7] => /?rss=1§ion=code [8] => /about [9] => /article/5/scrabble [10] => /article/7/cat-5-sucks [11] => /article/8/cat-5-rocks [12] => /code [13] => /code/4/what-makes-this-go [14] => /code/9/httpurl-class [15] => /design [16] => /downloads/HTTP_URL.phps [17] => /images/3.jpg [18] => /photos [19] => /send/colin/viebrock.ca [20] => ?count=5 [21] => http://alistapart.com/ [22] => http://blog.coggeshall.org/rss.php?version=2.0 [23] => http://ca.php.net/ [24] => http://derickrethans.nl/ [25] => http://gallery.menalto.com [26] => http://gravitonic.com/ [27] => http://imajes.info [28] => http://meetup.com [29] => http://powertrip.co.za/ [30] => http://textism.com/tools/textile/ [31] => http://textpattern.com [32] => http://toys.lerdorf.com/ [33] => http://trainedmonkey.com/ [34] => http://typographi.ca [35] => http://viebrock.ca/photos/Natalie/IMG_1013 [36] => http://www.edwardbear.org/serendipity/ [37] => http://www.s9y.org [38] => http://zeldman.com/ ) [form] => Array ( [0] => / [1] => /index.php ) )
See the full source here.
Copyright © 2000-2010 Colin Viebrock • All Rights Reserved
12 April 2004, 16:11 • PermaLink
12 April 2004, 23:05 • PermaLink
1 May 2004, 20:29 • PermaLink
12 November 2004, 12:17 • PermaLink
Very useful thing. Thank you for writing that class.
4 December 2005, 14:53 • PermaLink