PHP code example of cyve / url

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

    

cyve / url example snippets


use Cyve\Url\Url;

$url = new Url('https://user:[email protected]:8080/foo/bar?key=value#hash');

echo $url->scheme; // https
echo $url->username; // user
echo $url->password; // pwd
echo $url->host; // www.domain.tld
echo $url->subDomain; // www
echo $url->domain; // domain.tld
echo $url->tld; // tld
echo $url->port; // 8080
echo $url->path; // /foo/bar
echo $url->path[0]; // foo
echo $url->path[1]; // bar
echo $url->query; // key=value
echo $url->query->get('key'); // value
echo $url->query->get('undefined', 'default'); // default
echo $url->fragment; // hash