1. Go to this page and download the library: Download rowbot/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/ */
rowbot / url example snippets
use Rowbot\URL\URL;
// Construct a new URL object.
$url = new URL('https://example.com/');
// Construct a new URL object using a relative URL, by also providing the constructor with the base URL.
$url = new URL('path/to/file.php?query=string', 'http://example.com');
echo $url->href; // Outputs: "http://example.com/path/to/file.php?query=string"
// You can also pass an existing URL object to either the $url or $base arguments.
$url = new URL('https://example.org:123');
$url1 = new URL('foo/bar/', $url);
echo $url1->href; // Outputs: "https://example.org:123/foo/bar/"
// Catch the error when URL parsing fails.
try {
$url = new URL('http://2001::1]');
} catch (\Rowbot\URL\Exception\TypeError $e) {
echo 'Invalid URL';
}
use Rowbot\URL\URLSearchParams;
// Construct an empty list of search params.
$params = new URLSearchParams();
// Construct a new list from a query string. Remember that a leading "?" will be stripped.
$params = new URLSearchParams('?foo=bar');
// Construct a new list using an array of arrays containing strings. Alternatively, you could pass an
// object that implements the Traversable interface and whose iterator returns an array of arrays,
// with each array containing exactly 2 items.
$params = new URLSearchParams([
['foo', 'bar'],
['foo', 'bar'] // Duplicates are allowed!
['one', 'two']
]);
// Iterate over a URLSearchParams object.
foreach ($params as $index => $param) {
if ($index > 0) {
echo '&';
}
echo $param[0] . '=' . $param[1];
}
// Above loop prints "foo=bar&foo=bar&one=two".
// Construct a new list using an object
$obj = new \stdClass();
$obj->foo = 'bar';
$params = new URLSearchParams($obj);
// Copy an existing URLSearchParams object into a new one.
$params1 = new URLSearchParams($params);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.