linkValidator is a PHP class that can validate a URL. It can return true or false, and it is able to return a full error message.
Here are some key features of "linkValidator":
· Follows redirection headers when status is an 300, 301, 302 till 399.
· Checks with the HTTP/1.0 and/or HTTP/1.1. protocol.
· Doesn't use any system or command line tools.
· Easy to implement.
· PHP4 and PHP5 compatible.
Examples
//EXAMPLE CODE 1
//check one URL
$linkValidator = new linkValidator('http://www.daantje.nl/');
echo $linkValidator->message();
echo "< hr >";
echo $linkValidator->status();
echo "< br >".($linkValidator->status() ? "worked" : "failed");
//EXAMPLE CODE 2
//check multiple URL's
$linkValidator = new linkValidator();
$checkThese = array(
"http://www.rokenmoetmogen.nl/",
"http://www.daantje.nl/",
"http://www.daantje.nl/",
"http://www.daantje.nl/blah.html",
"http://www.google.nl/"
);
foreach($checkThese as $url){
$linkValidator->linkValidator($url);
echo "$url< br >";
echo $linkValidator->message();
echo ($linkValidator->status() ? " - worked" : " - failed") ."< br >";
echo "< hr >";
flush();
}
//EXAMPLE CODE 3
//do it all manualy
$linkValidator = new linkValidator();
//disable redirects... Show when it's a status 30x
$linkValidator->follow_redirects(FALSE);
$array = $linkValidator->disectURL('http://www.daantje.nl/index.php');
$linkValidator->open($array['host'],$array['port'],$array['get'],'http://www.daantje.nl/','http://www.whole.world/fake/referer.html');
echo $linkValidator->message();
echo ($linkValidator->status() ? " - worked" : " - failed") ."< br >";
//EXAMPLE CODE 4
//check if it's allowd from this file as referer...
$linkValidator = new linkValidator('http://www.daantje.nl/index.php',$_SERVER['REQUEST_URI']);
echo $linkValidator->message();
echo "< hr >";
echo $linkValidator->status();
echo "< br >".($linkValidator->status() ? "worked" : "failed");
What's New in This Release:
· The class follows redirects when status is between 300 and 399Default this option is set TRUE!! This can be disabled as shown in example 4 in this file, with the follow_redirects(). Thanx to Felix Nagel for the feature request.
· Also tested and works on PHP4 and PHP5.
· Fixed PHP warnings.
Product's homepage