PHP code example of talesoft / tale-uri

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

    

talesoft / tale-uri example snippets


use function Tale\uri_parse;

$uri = uri_parse('https://google.com/search');
//$uri is a strict implementation of PSR-7's UriInterface

echo $uri->getScheme(); //"https"
echo $uri->getHost(); "google.com"
echo $uri->getPath(); //"/search"

echo $uri->withHost("talesoft.codes"); "https://talesoft.codes/search"

use Psr\Http\Message\UriFactoryInterface;
use Tale\UriFactory;

$container->add(UriFactory::class);

//...

$uriFactory = $container->get(UriFactoryInterface::class);

$uri = $uriFactory->createUri('https://example.com#test');

echo $uri->getFragment(); //"test"