PHP code example of arne-groskurth / url
1. Go to this page and download the library: Download arne-groskurth/url library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
arne-groskurth / url example snippets
use ArneGroskurth\Url\Url;
// construct url
$url = new Url();
$url->setHost('domain.tld');
$url->setScheme('ftps');
// parses given url
$url = new Url('http://username:[email protected]: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();