PHP: How to resolve a relative url
问题 I need a function that given a relative URL and a base returns an absolute URL. I\'ve searched and found many functions that do it different ways. resolve(\"../abc.png\", \"http://example.com/path/thing?foo=bar\") # returns http://example.com/abc.png Is there a canonical way? On this site I see great examples for python and c#, lets get a PHP solution. 回答1: Perhaps this article could help? http:// nashruddin.com/PHP_Script_for_Converting_Relative_to_Absolute_URL Edit: reproduced code below