简体   繁体   中英

PHP Equivalent to Perl's URI::URL

I'm in the process of rewriting a Perl-based web crawler I wrote nearly 8 years ago in PHP. I used the quite handy URI::URL module in perl to do things like:

$sourceUrl = '/blah.html';
$baseHost = 'http://www.example.com';
my $url = URI::URL->new($sourceUrl, $baseHost);
return $url->abs;

returns: ' http://www.example.com/blah.html '

the parse_url function in PHP is quite handy, but is there something more robust? Specifically something that will give the above functionality?

也许Zend_Uri是您的寻找?

print $baseHost . $sourceURL;

Am I missing something? Your way seems needlessly overcomplicated.

I did a bit of searching on the PEAR archive, and my first-guess approximation of URI::URL is Net_URL2 . Maybe you want to give that a shot?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM