Login   Register  
PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Kaloyan Kirilov  >  Mrasnika's URL validator  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: An example
Class: Mrasnika's URL validator
Validate and parse HTTP or FTP URLs
Author: By
Last change:
Date: 10 years ago
Size: 1,754 bytes
 

Contents

Class file image Download
<?

// URL VALIDATION SAMPLE STRINGS
// --------------------------------------------------------

//$url = "https://domain.gov";
//$url = "http://www.domain.gov";
//$url = "ftp://sub_domain.x_top.domain.gov";
//$url = "http://sub_domain.ww_111.domain.info";
//$url = "http://sub_domain.ww_111.domain.info:80/21312312/sdfdsgsdf/";
//$url = "http://sub_domain.ww_111.domain.info:80/21312312/sdfdsgsdf/sadf";
//$url = "http://mrasnika:password@sub_domain.ww_111.domain.info:80/21312312/sdfdsgsdf/sadf";
//$url = "http://sub_domain.ww_111.domain.info:80/21312312/sdfdsgsdf/sadf/?Login=123&df=111";
$url "http://zzzz.fff.gggg.sub_domain.ww_111.domain.info:80/21312312/sdfdsgsdf/sadf/?23,4,5,,0,78,1,1";





require(
"./url-validation.class.php");





// URL VALIDATION CONSTRUCTOR
// --------------------------------------------------------
$URL = new mrsnk_URL_validation(
    
$url,
    
MRSNK_URL_DO_PRINT_ERRORS,
    
MRSNK_URL_DO_NOT_CONNECT_2_URL);





// URL VALIDATION PUBLIC METHODS
// --------------------------------------------------------

$valid $URL->isValid();
//    Boolean method, that checks
//    whether provided URL is valid
//    or not.
echo ($valid)?"URL is valid":"URL's not valid";
echo 
"<hr>";


$PARTS $URL->parse();
//    This method returns an array
//    with all the elements of the URL.
//    If validation fails, this method
//    returns NULL.

echo "<pre>";
print_r($PARTS);
echo 
"</pre><hr>";



$URL->url 'http://www.estreambg.com';
// You can change the URL in the class
// and run the isValid() and parse() methods
// to handle the new URL

echo ($URL->isValid())?$URL->url." is valid":$URL->url." isn't valid";
echo 
"<pre>";
print_r($URL->parse());
echo 
"</pre><hr>";

?>