URL Validation Class In PHP

A couple of days ago I’ve been struggling with URL validation in PHP. And I found a URL validation class from phpclasses.org which I think is great and does what I need. And to use it, is really simple. Besides validating URLs, this class can also parse the URL, so you can get all the URL details.

This URL validation class was developed by Kaloyan Kirilov Tzvetkov; all credit goes to him.

Here is the example to use it:

require("url-validation.class.php");
$URL = new mrsnk_URL_validation( $url,
	MRSNK_URL_DO_NOT_PRINT_ERRORS,
	MRSNK_URL_DO_NOT_CONNECT_2_URL);

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

It’s pretty handy and saves a headache, isn’t it?

Download URL validation class for PHP.