January 7, 2011 by Ivan Kristianto
URL Validation Class In PHP

A couple 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 do what i need. And to use it, is really simple. Beside validate url, this class also can parse the url, so you can get all the url details.
This url validation class is develop by Kaloyan Kirilov Tzvetkov, all credits is goes to him. You can download the script at the end of this article.
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 safe your headache, isn’t it?
Download url validation class for PHP.
[TIPS] How To Skip 60 seconds When Downloading DepositFiles
Google Instant: Get What You Search Instantly



Hi Ivan!
I'll suggest using the FILTER_VAR. With FILTER_VAR you can validate url's, emails and more.
See: http://www.php.net/manual/en/filter.filters.validate.php
- spam
- offensive
- disagree
- off topic
LikeHi Luis,
what a great info! Thanks mate :)
- spam
- offensive
- disagree
- off topic
Like