gabrieljmj / urlparser
This package is abandoned and no longer maintained.
No replacement package was suggested.
To parse an URL to get informations
dev-master
2014-09-14 02:38 UTC
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2019-02-20 19:40:51 UTC
README
To parse an URL to get informations.
##Download and autoload ###Via Composer ####Download
{ "require": { "gabrieljmj/urlparser": "dev-master" } }
####Autoload
{ "autoload": { "psr-4": { "Gabrieljmj\\UrlParser\\": "vendor/gabrieljmj/urlparser/src/Gabrieljmj/UrlParser/", "Test\\": "tests/" } } }
##Examples
use Gabrieljmj\UrlParser\UrlParser; $urlParser = new UrlParser(); $urlData = $urlParser->url('https://github.com/search?q=some+search'); echo 'Protocol: ' . $urlData->getProtocol() . "\n" . 'Host: ' . $urlData->getHost() . "\n" . 'Tld: ' . $urlData->getTld() . "\n" . 'Path: ' . print_r($urlData->getPath(), true) . "\n" . 'Query: ' . print_r($urlData->getQuery, true);
Returns:
Protocol: https Host: github.com Tld: .com Path: Array([0] => search) Query: Array([q] => some+search)
URL has subdomain: Pass as second param on Gabrieljmj\UrlParser\UrlParser::url(string $url [, boolean $hasSubsmain = false])
the value true
.