arne-groskurth / url
Url is a small PHP class that helps dealing with Urls.
Installs: 22 294
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.3
Requires (Dev)
- phpunit/phpunit: ^5.5
This package is not auto-updated.
Last update: 2021-10-30 04:05:52 UTC
README
Url is a small PHP class that helps dealing with Urls.
Setup
$ composer require arne-groskurth/url
Examples
<?php use ArneGroskurth\Url\Url; // construct url $url = new Url(); $url->setHost('domain.tld'); $url->setScheme('ftps'); // parses given url $url = new Url('http://username:password@www.test.com:8080/some/path.html?one=1&two=2#myfrag'); // modify parts $url->setPort(80); $url->removeQueryParameter('two'); $url->setQueryParameter('three', 3); // get back url string print $url->getUrl(); // avoid some parts on return print $url->getUrl(Url::ALL - Url::CREDENTIALS); print $url->getUrl(Url::SCHEME + Url::PORT); // interpret link relative to some url print $url->resolveRelativeUrl('../other/path.html')->getUrl(); print $url->resolveRelativeUrl('//domain.tld/')->getUrl();