Last Updated: February 25, 2016
·
485
· wasinsandiego

Great little php URL parser

You can get varied results with parse_url in php. This class gets great results, check it out:
https://github.com/monkeysuffrage/phpuri

Example

require 'phpuri.php';
$uri = phpUri::parse('https://www.google.com/foo?q=bar');
echo $uri->scheme;
echo $uri->authority;
echo $uri->path;
echo $uri->query;
//==> https://
//==> google.com
//==> foo
//==> ?q=bar

Benchmarks

rel2abs:         successes -> 26, fails => 9, time: 0.001301
url_to_absolute: successes -> 32, fails => 3, time: 0.0029089999999999
phpuri:          successes -> 35, fails => 0, time: 0.002402