PHP code example of malenki / url

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

    

malenki / url example snippets


$u = new Url('http://username:password@hostname:8080/path?arg=value#anchor');
echo $u->credential;
echo $u->host;

// you can change some parts using this way:
$u->credential->user = 'login';
$u->host = 'example.org'
$u->query->foo = 'bar';

// you can use other way too:
$u->user('login')->host('example.org')->query(array('foo', 'bar'));

// toString available:
echo $u; // http://login:[email protected]:8080/path?arg=value&foo=bar#anchor

$u = new Url('http://username:password@hostname:8080/path?arg=value#anchor');
$u->user('login')->host('example.org')->query(array('foo', 'bar'));

echo $u->no_port->disable_credential;
var_dump($u->has_port);

$u = new Url('http://username:password@hostname:8080/path?arg=value#anchor');
$u->anchor->clear; // delete anchor
$u->path->add('other'); // add branch to path
$u->query->arg = 'other_value'; // Changed one arg of the query string

$u = new Url('http://username:password@hostname:8080/path?arg=value#anchor');
$u->path = 'other/path'; //or using array
$u->anchor = 'new_anchor';