Location: PHPKode > scripts > URL Utility > url-utility/example.URLUtility.php
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>URLUtility</title>
</head>
<body>
<pre>
<?PHP

require("class.URLUtility.php");
$link = new URLUtility();

echo "Current document:\n\n" . output($link) . "\n\n";



$link->setScheme("https");
$link->setHost("local_host");
$link->setPort("4242");
$link->setPath("/any/path/");
$link->setFileName("script_file.php");

echo "<hr>\nsetScheme('https')\nsetHost('local_host')\nsetPort('4242')\nsetPath('/any/path/')\nsetFileName('script_file.php')\n\n" . output($link) . "\n\n";



// --- SET ---

echo "<hr>";

$link->setQuery("one=[1]&two=[2]&three=[3]");
echo "<hr>\nsetQuery('one=[1]&two=[2]&three=[3]')\n\n" . output($link) . "\n\n";

$link->setFilePath("/path/to/script.php");
echo "<hr>\nsetFilePath('/path/to/script.php')\n\n" . output($link) . "\n\n";

$link->setFilePathQuery("/path/to/another/script.php?four=[4]&five=[5]");
echo "<hr>\nsetFilePathQuery('/path/to/another/script.php?four=[4]&five=[5]')\n\n" . output($link) . "\n\n";

$link->setSchemeHost("http://www.local-host.ch");
echo "<hr>\nsetSchemeHost('http://www.local-host.ch')\n\n" . output($link) . "\n\n";

$link->setSchemeHostPath("http://www.local_host.ch");
echo "<hr>\nsetSchemeHostPath('http://www.local_host.ch')\n\n" . output($link) . "\n\n";

$link->setSchemeHostFilePath("http://www.localhost.ch");
echo "<hr>\nsetSchemeHostFilePath('http://www.localhost.ch')\n\n" . output($link) . "\n\n";



// --- MERGE ---

echo "<hr>";

$link->mergeQuery("one=[1]&two=[2]&three=[3]");
echo "<hr>\nmergeQuery('one=[1]&two=[2]&three=[3]')\n\n" . output($link) . "\n\n";

$link->mergeFilePath("./path/to/yet/another/php_script.php");
echo "<hr>\nmergeFilePath('./path/to/yet/another/php_script.php')\n\n" . output($link) . "\n\n";

$link->mergeFilePathQuery("../?six=[6]&seven=[7]");
echo "<hr>\nmergeFilePathQuery('../?six=[6]&seven=[7]')\n\n" . output($link) . "\n\n";

$link->mergeSchemeHost("http://local-host:4244/no/path/at/all.php");
echo "<hr>\nmergeSchemeHost('http://local-host:4244/no/path/at/all.php')\n\n" . output($link) . "\n\n";

$link->mergeSchemeHostPath("http://local_host:4243/no/path/at/all.php");
echo "<hr>\nmergeSchemeHostPath('http://local_host:4243/no/path/at/all.php')\n\n" . output($link) . "\n\n";

$link->mergeSchemeHostFilePath("http://localhost:4242/no/path/at/all.php");
echo "<hr>\nmergeSchemeHostFilePath('http://localhost:4242/no/path/at/all.php')\n\n" . output($link) . "\n\n";



function output($link)
{
    return
        "getURL()                : " . $link->getURL()                . "\n" .
        "getSchemeHost()         : " . $link->getSchemeHost()         . "\n" .
        "getSchemeHostPath()     : " . $link->getSchemeHostPath()     . "\n" .
        "getSchemeHostFilePath() : " . $link->getSchemeHostFilePath() . "\n" .
        "getScheme()             : " . $link->getScheme()             . "\n" .
        "getHost()               : " . $link->getHost()               . "\n" .
        "getPort()               : " . $link->getPort()               . "\n" .
        "getPath()               : " . $link->getPath()               . "\n" .
        "getFileName()           : " . $link->getFileName()           . "\n" .
        "getFilePath()           : " . $link->getFilePath()           . "\n" .
        "getQuery()              : " . $link->getQuery()              . "\n" .
        "getFilePathQuery()      : " . $link->getFilePathQuery()      . "\n";
}

?>
</pre>
</body>
</html>
Return current item: URL Utility