<?php
/**
* Example of UrlTool class usage.
*
* @author Hossamzee (hossam_zee@yahoo.com).
* @date 11 Feb 2012.
*/
require_once("./url.tool.class.php");
/* Url to be parsed, validated, and checked. */
$url = "http://www.example.org/path?querystring#fragment";
/* Create a new instance of URL class. */
$urlToolObj = new UrlTool();
/* Check if the url is valid (lexically). */
if ($urlToolObj->parseUrl($url, $error) !== false)
{
$result = sprintf("(%s) is lexically valid.\n", $url);
}
else
{
$result = sprintf("(%s) is lexically invalid.\nError: %s\n", $url, $error);
}
/* Print the result. */
echo "<pre>\n";
echo $result;
echo "</pre>";
|