: PHP W3 Validator API, Is this good? I was trying to find a way to see if my site's code was valid or not but I continuously going over to W3 Validator so I decided to make an "API" however
I was trying to find a way to see if my site's code was valid or not but I continuously going over to W3 Validator so I decided to make an "API" however it really isn't!
I just wanted to know if anybody can find a better solution to the one I have made.
This is what I currently use, with the usage of ?uri=http://www.mydomain.com :
<?php
if(!$_GET['uri']) {
echo "No URI!";
}
else {
$CheckURI = "http://validator.w3.org/check?uri=".$_GET['uri'];
$URL = file_get_contents($CheckURI);
$Start = strpos($URL, "<title>") + 7;
$End = strpos($URL, "</title>");
$Title = substr($URL, $Start, $End-$Start);
if(preg_match('[Invalid]',$Title)) {
//Code is INVALID
echo "<a href='$CheckURI' title='This is not good!' target='_BLANK'>INVALID Source</a>";
}
elseif(preg_match('[Valid]',$Title)) {
//Code is VALID
echo "<a href='$CheckURI' title='Check It Yourself!' target='_BLANK'>Valid Source</a>";
}
else {
//It Went WRONG
echo "";
}
}
More posts by @Shelton105
1 Comments
Sorted by latest first Latest Oldest Best
I don't think W3C had your use case in mind when they made the validator. Why not run your own? The script you made is going to be very slow because it is relaying all requests. Also, your script won't run cleanly on E_STRICT. Also, your script doesn't encode URI parameters. Also, you are unnecessarily using regexes. Also, you are not HTML encoding your URI.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.