PHP code example of thesmart / php-url

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

    

thesmart / php-url example snippets


$url = new Url('http://example.com/');
echo (string)$url;

$url = new Url();
$url->setScheme('https://')->setHost('www.reddit.com')->setPath('/r/programming');
echo (string)$url;

$url = new Url('http://example.com?x=0&a=1&b=2');
var_dump($url->getQuery());
var_dump($url->getQueryStr());

$url = new Url('http://example.com');
var_dump((string)$url);
$url = new Url('http://example.com/');
var_dump((string)$url);
$url = new Url('http://example.com');
$url->setPath('/');
var_dump((string)$url);