Forum Moderators: coopster
So I'm looking for this tag, splitting it with explode, accounting for whether it begins with [,...] or '/', and it occurs to me: this is a whole lot of work, it's pretty standard http protocol stuff, and anyone who put some time into writing a class like this would have done a lot better at writing a class like this than I'd spend in the limited time I have.
Has anyone come across a class like this, or used one? Basically a class that can resolve relative uri's, or take multiple uris to put together the 'real' uri - like your basic page url, and relative uri's for the links and images etc.
For relative URIs can't you get them by subtracting $_SERVER['DOCUMENT_ROOT'] out of the value returned by realpath()?
I thought there was a PEAR class for doing complicated URI stuff...
What I'd like is a function or class that lets me take the url of a file, and then a url that it has in a <BASE HREF> tag, and put them together to come up with the base url that I need to use when grabbing relative uri's in the page. Same function, or related function, allows you to take the uri of the page or the uri modified with <BASE HREF>, and a relative uri from a link or image on the page, and returns the full url. This probably wouldn't be so hard to write if you really had brain processor resources left to use, and time to think about the various possibilities - I'm low on both now, so I know anything I'd write would be slipshod compared to a well-thought-out solution.
<edit: guess which page turns up first googling php class resolve uri? hint: it contains forum88 in the url>
<edit: ergophobe, you're right, I didn't check the big category 'networking' in PEAR, there's a class here Net_URL, hope it isn't too big and bulky since I might have to call this one lots in big loops)>