1. Go to this page and download the library: Download gravitymedia/uri 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/ */
gravitymedia / uri example snippets
// quire 'vendor/autoload.php';
// import classes
use GravityMedia\Uri\Uri;
// create URI object from string
$uri = Uri::fromString('http://username:[email protected]:8080/this/is/a/path?argument=value#my_fragment');
// dump scheme
var_dump($uri->getScheme()); // string(4) "http"
// dump authority
var_dump($uri->getAuthority()); // string(29) "username:[email protected]"
// dump user info
var_dump($uri->getUserInfo()); // string(17) "username:password"
// dump host
var_dump($uri->getHost()); // string(11) "example.com"
// dump port
var_dump($uri->getPort()); // int(8080)
// dump path
var_dump($uri->getPath()); // string(15) "/this/is/a/path"
// dump argument
var_dump($uri->getQuery()); // string(14) "argument=value"
// dump fragment
var_dump($uri->getFragment()); // string(11) "my_fragment"
// remove path and remove fragment
$uri = $uri->withPath('')->withFragment('');
// dump URI
var_dump($uri->toString()); // string(56) "http://username:[email protected]:8080?argument=value"