PHP code example of php-dto / uri

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

    

php-dto / uri example snippets




$uri = new \PhpDto\Uri\Uri('https://[email protected]:42?query#');

echo $uri->get(); //will print https://[email protected]:42?query#
echo (string) $uri; //will print https://[email protected]:42?query#

print_r($uri->getComponents());
//will print
array(
  'scheme' => 'https',           // the URI scheme component
  'user' => 'foo',              // the URI user component
  'pass' => null,               // the URI pass component
  'host' => 'test.example.com', // the URI host component
  'port' => 42,                 // the URI port component
  'path' => '',                 // the URI path component
  'query' => 'query',           // the URI query component
  'fragment' => '',             // the URI fragment component
);

new \PhpDto\Uri\Uri('http://test.com', ['https',]); //will throw \PhpDto\Uri\Exception\UriException (allows only `https` scheme)
shell script
composer