PHP code example of filippo-toso / uri

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

    

filippo-toso / uri example snippets


use FilippoToso\URI\URI;

$url = 'http://www.example.com/dir/sub/file.php?name=john&[email protected]';

$relativeUrl = '../../hello.php';

$newUrl = URI::make($url)
    ->relative($relativeUrl) // Changes the url to: http://www.example.com/hello.php?name=john&[email protected]
    ->url();


$url = 'https://www.example.com/?utm_source=summer-mailer&utm_medium=email&utm_campaign=summer-sale';

$newUrl = URI::make($url)->remove(function ($key, $value) {
    return (bool)preg_match('#^utm_#si', $key);
})->url();