PHP code example of web / url

1. Go to this page and download the library: Download web/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/ */

    

web / url example snippets


Url::parse('https://user:[email protected]:5500/path/example.html?id=123&user=test#section');
// Results:
// Web\Url\Parser\Parser Object
// (
//   [hash] => #section
//   [search] => ?id=123&user=test
//   [query] => id=123&user=test
//   [slashes] => //
//   [auth] => user:pass
//   [protocol] => https:
//   [host] => www.example.com:5500
//   [href] => https://user:[email protected]:5500/path/example.html?id=123&user=test#section
//   [pathname] => /path/example.html
//   [port] => 5500
//   [uri] => /path/example.html?id=123&user=test
//   [hostname] => example.com
//   [origin] => https://user:[email protected]:5500
//   [username] => user
//   [password] => pass
//   [www] => www.
// )

new Url('path/example.html?id=123&user=test#section', 'https://user:[email protected]:5500/');
// Results:
Web\Url\Url Object
// (
//   [hash] => #section
//   [password] => pass
//   [username] => user
//   [search] => ?id=123&user=test
//   [query] => id=123&user=test
//   [origin] => https://user:[email protected]:5500
//   [slashes] => //
//   [searchParams] =>
//   [auth] => user:pass
//   [protocol] => https:
//   [www] => www.
//   [host] => www.example.com:5500
//   [href] => https://user:[email protected]:5500/path/example.html?id=123&user=test#section
//   [pathname] => /path/example.html
//   [port] => 5500
//   [uri] => /path/example.html?id=123&user=test
//   [hostname] => example.com
// )