1. Go to this page and download the library: Download simplon/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/ */
simplon / url example snippets
$url = new Url(
'http://foo.bar.com/en/test/challenge?utm_source=source&utm_campaign=campaign&utm_medium=medium#hello-world'
);
$url->getProtocol(); // http
$url->getHost(); // foo.bar.com
$url->getSubDomain(); // foo
$url->getDomain(); // bar
$url->getTopLevelDomain(); // com
$url->getPath(); // /en/test/challenge
$url->getAllQueryParams(); // ['utm_source' => 'source', ...]
$url->getQueryParam('utm_source'); // source
$url->getPathSegment(1); // en
$url->getPathSegment(2); // test
$url->getFragment(); // hello-world
$url = new Url(
'ftp://peter:[email protected]:21'
);
$url->getUser(); // peter
$url->getPass(); // sunny
$url->getPort(); // 21