1. Go to this page and download the library: Download mtchabok/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/ */
mtchabok / url example snippets
use \Mtchabok\Url\Url;
$url = new Url('https://www.domain.com/dir1/dir2/file.ext?param1=val1¶m2=val2');
$url = Url::newUrl('https://www.domain.com/dir1/dir2/file.ext?param1=val1¶m2=val2');
$url = Url::newUrl()
->setScheme('https')
->setAuthority('www.domain.com')
->setPath('/dir1/dir2/file.ext')
->setQuery('param1=val1¶m2=val2')
;
use \Mtchabok\Url\Url;
$url = Url::newUrl();
// check scheme set
$url->hasScheme(); // return bool
// check userInfo set
$url->hasUserInfo(); // return bool
$url->hasUser(); // return bool
$url->hasPass(); // return bool
// check host set
$url->hasHost(); // return bool
// check port set
$url->hasPort(); // return bool
// check path set
$url->hasPath(); // return bool
// check query set
$url->hasQuery(); // return bool
// and ...
use \Mtchabok\Url\Url;
$url = Url::newUrl();
// scheme
$url->getScheme(); // return current scheme or empty string
$url->scheme; // return current scheme or null
$url->getScheme('file'); // reutrn current scheme or 'file'
// user info
$url->getUserInfo(); // return current userinfo or empty string
$url->getUserInfo('test:123'); // return current userinfo or 'test:123'
// host
$url->getHost(); // return current host or empty string
$url->getHost('host.org'); // return current host or 'host.org'
// path
$url->getPath(); // return current path or empty string
$url->getPath('/dir1/dir2/file'); // return current path or '/dir1/dir2/file'
use \Mtchabok\Url\Url;
$url = Url::newUrl('https://www.domain.com/dir1/dir2/file.ext');
$url2 = $url->withHost('site.com'); // return new Url Object with host 'site.com'
$url->equalsHost($url2->getHost()); // return false
$url->equalsHost($url2); // return false
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.