Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Hossam Suliman  >  URL Tool  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example of class usage
Class: URL Tool
Parse and check the existence of a given URL
Author: By
Last change:
Date: 2 years ago
Size: 682 bytes
 

Contents

Class file image Download
<?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>";