1. Go to this page and download the library: Download josantonius/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/ */
josantonius / url example snippets
/**
* If no URL is provided, the URL of the current page will be generated.
*
* The generated URL will exclude ports 80 and 443 and
/**
* The authority, in "[user-info@][host][:port]" format.
*
* @var string URL authority or empty string.
*/
public readonly string $authority;
/**
* The base URL, in "[scheme:][//domain][:port]" format.
*
* @var string Base URL or empty string.
*/
public readonly string $base;
/**
* The path basename, in "[filename][.extension]" format.
*
* @var string URL path basename or empty string.
*/
public readonly string $basename;
/**
* The path dirname, in "[dirname]" format.
*
* @var string URL path dirname or empty string.
*/
public readonly string $dirname;
/**
* The path basename extension, in "[extension]" format.
*
* @var string URL path basename extension or empty string.
*/
public readonly string $extension;
/**
* The path filename, in "[filename]" format.
*
* @var string URL path filename or empty string.
*/
public readonly string $filename;
/**
* URL fragment in "[fragment]" format.
*
* @var string URL fragment or empty string.
*/
public readonly string $fragment;
public readonly string $full;
/**
* URL hashed fragment in "[#fragment]" format.
*
* @var string URL hashed fragment or empty string.
*/
public readonly string $hash;
/**
* URL host in "[subdomain.][domain][.tld]" format.
*
* @var string URL host or empty string.
*/
public readonly string $host;
/**
* URL path in "[path]" format.
*
* @var string URL path or empty string.
*/
public readonly string $path;
/**
* URL query parameters in array format.
*
* @var array<string, mixed> URL query parameters or empty string.
*/
public readonly array $parameters;
/**
* URL password in "[password]" format.
*
* @var string URL password or empty string.
*/
public readonly string $password;
/**
* URL port in "[port]" format.
*
* @var string URL port or empty string.
*/
public readonly int|string $port;
/**
* URL scheme in "[scheme]" format.
*
* @var string URL scheme or empty string.
*/
public readonly string $scheme;
/**
* URL path segments in array format.
*
* @var string[] URL path segments or empty string.
*/
public readonly array $segments;
/**
* URL query in "[query]" format.
*
* @var string URL query or empty string.
*/
public readonly string $query;
/**
* URL username in "[username]" format.
*
* @var string URL username or empty string.
*/
public readonly string $username;
use Josantonius\Url\Url;
$url = new Url();
use Josantonius\Url\Url;
$url = new Url('https://domain.com');
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com
$url->authority; // "domain.com"
$url = new Url('https://user:[email protected]:90/en/');
$url->authority; // "user:[email protected]:90"
$url = new Url('https://user:[email protected]/en/');
$url->authority; // "user:[email protected]"
$url = new Url('https://sub.domain.com/en/');
$url->authority; // "sub.domain.com"
use Josantonius\Url\Url;
$url = new Url(); // https://user:[email protected]:80/en/
$url->base; // "https://domain.com"
$url = new Url('https://domain.com:80/?tag=bug');
$url->base; // "https://domain.com:80"
$url = new Url('https://domain.com/en/');
$url->base; // "https://domain.com"
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com/search.php
$url->basename; // "search.php"
$url = new Url('https://domain.com/en/web/docs/search.php?tag=bug');
$url->basename; // "search.php"
$url = new Url('https://domain.com/en/web/docs?tag=bug');
$url->basename; // "docs"
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com/search.php
$url->dirname; // "/"
$url = new Url('https://domain.com/en/web/docs/search.php?tag=bug');
$url->dirname; // "/en/web/docs"
$url = new Url('https://domain.com/en/web/docs?tag=bug');
$url->dirname; // "/en/web"
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com/search.php
$url->extension; // "php"
$url = new Url('https://domain.com/en/web/docs/search.php?tag=bug');
$url->extension; // "php"
$url = new Url('https://domain.com/en/web/docs?tag=bug');
$url->extension; // ""
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com/search.php
$url->filename; // "search"
$url = new Url('https://domain.com/en/web/docs/search.php?tag=bug');
$url->filename; // "search"
$url = new Url('https://domain.com/docs?tag=bug');
$url->filename; // "docs"
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com#top
$url->fragment; // "top"
$url = new Url('https://domain.com/en/web/docs#top');
$url->fragment; // "top"
$url = new Url('https://domain.com');
$url->fragment; // ""
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com:80
$url->full; // "https://domain.com"
$url = new Url('https://user:[email protected]:90/en/');
$url->full; // "https://user:[email protected]:90/en/"
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com#top
$url->hash; // "#top"
$url = new Url('https://domain.com/en/web/docs#top');
$url->hash; // "#top"
$url = new Url('https://domain.com');
$url->hash; // ""
use Josantonius\Url\Url;
$url = new Url(); // https://sub.domain.com
$url->host; // "sub.domain.com"
$url = new Url('https://sub.domain.com/en/web/docs#top');
$url->host; // "sub.domain.com"
$url = new Url('https://domain.com');
$url->host; // "domain.com"
$url = new Url('https://localhost');
$url->host; // "localhost"
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com/en
$url->path; // "/en/web/docs/search.php"
$url = new Url('https://domain.com/en/web/docs/search.php');
$url->path; // "/en/web/docs/search.php"
$url = new Url('https://domain.com/en/web/docs/');
$url->path; // "/en/web/docs/"
$url = new Url('https://domain.com/en?tag=bug');
$url->path; // "/en"
$url = new Url('https://domain.com?tag=bug');
$url->path; // ""
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com/en?tag=bug&order=asc#top
$url->parameters; // ["tag" => "bug", "order" => "asc"]
$url = new Url('https://domain.com/en/web/docs/search.php');
$url->parameters; // ""
use Josantonius\Url\Url;
$url = new Url(); // https://:[email protected]
$url->password; // "pass"
$url = new Url('https://user:[email protected]');
$url->password; // "pass"
$url = new Url('https://[email protected]');
$url->password; // ""
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com:90
$url->port; // 90
$url = new Url(); // https://domain.com:80
$url->port; // ""
$url = new Url(); // https://domain.com:443
$url->port; // ""
$url = new Url('https://domain.com:80/en/');
$url->port; // 80
$url = new Url('https://domain.com:443/en/');
$url->port; // 443
$url = new Url('https://domain.com/en/');
$url->port; // ""
use Josantonius\Url\Url;
$url = new Url(); // http://domain.com
$url->scheme; // "http"
$url = new Url('https://domain.com');
$url->scheme; // "https"
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com?tag=bug
$url->segments; // []
$url = new Url('https://domain.com/en/web/docs/search.php');
$url->segments; // ['en', 'web', 'docs', 'search.php']
use Josantonius\Url\Url;
$url = new Url(); // https://domain.com?tag=bug
$url->query; // "tag=bug"
$url = new Url('https://domain.com?tag=bug&order=asc#top');
$url->query; // "tag=bug&order=asc"
$url = new Url('https://domain.com');
$url->query; // ""
use Josantonius\Url\Url;
$url = new Url(); // https://[email protected]
$url->username; // "user"
$url = new Url('https://:[email protected]');
$url->username; // ""
$url = new Url('https://user:[email protected]');
$url->username; // "user"
$url = new Url('https://domain.com');
$url->username; // ""
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.