W3C local validation php class?
Moderator: General Moderators
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
W3C local validation php class?
Is there a way I can use php to validate with w3c my generated pages?
So I could run all the pages (views) on my website and show a table of results of each page and if they passed w3c validation?
i.e
page | url | w3c
----------------
home | http://localhost/index | pass
about | http://localhost/about/ | pass
contact | http://localhost/contact | fail
Another reason for this, is that I could then build additional columns for PHPUnit & Selenium. Just for a quick overview if any other developers or myself have broken something it can be sorted immediately.
Cheers
So I could run all the pages (views) on my website and show a table of results of each page and if they passed w3c validation?
i.e
page | url | w3c
----------------
home | http://localhost/index | pass
about | http://localhost/about/ | pass
contact | http://localhost/contact | fail
Another reason for this, is that I could then build additional columns for PHPUnit & Selenium. Just for a quick overview if any other developers or myself have broken something it can be sorted immediately.
Cheers
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: W3C local validation php class?
I'm reasonably sure Tidy can do validation. Let me check.
All it requires is a SGML parser that interprets the rules in the DTD.
EDIT | I can't seem to find anything about validation using Tidy.
You can always POST the HTML to the W3C validator. This is basically what Firebug does when you use "Validate Local HTML".
All it requires is a SGML parser that interprets the rules in the DTD.
EDIT | I can't seem to find anything about validation using Tidy.
You can always POST the HTML to the W3C validator. This is basically what Firebug does when you use "Validate Local HTML".
Re: W3C local validation php class?
The w3c validation service has an API - http://validator.w3.org/docs/api.html
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: W3C local validation php class?
Sounds good.Chris Corbyn wrote:You can always POST the HTML to the W3C validator. This is basically what Firebug does when you use "Validate Local HTML".
Do i have to use AJAX or can I do it will plain PHP?
I will look at the api.
Cheers All
Re: W3C local validation php class?
If you're using the API, it's a RESTful service. create an HTTP request using something like
Code: Select all
$result = file_get_contents('http://validator.w3.org/check' . $parameters);-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: W3C local validation php class?
Cool thanks, I will give it a try.
I have been having some issues with the http request. I keep getting connection closed.
I have been having some issues with the http request. I keep getting connection closed.
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: W3C local validation php class?
It's simply best to use cURL. When you use the editor on my site to import CSS it actually validates it by creating a temporary file on the server, using cURL to validate (and then scan the resulting page for valid or invalid) and in the process completely offloads the entire validation process to the W3C server. Since they update the validator every so often you'll always be using the latest validation algorithms, doesn't get any better then that. The only possible downside is if the XHTML code on the validation page changes and breaks cURL's ability to figure out if the page is valid or not...but it's a small price to pay considering the trade-off's.
Re: W3C local validation php class?
It's definitely not simply best to use cURL, as it's way more complicated than a simple file_get_contents call. The reason it might be failing for you is that you might have safe mode in the PHP settings.
Also, the API is a webservice, it won't give a different response format when the validator is updated..
Also, the API is a webservice, it won't give a different response format when the validator is updated..
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: W3C local validation php class?
1+It's definitely not simply best to use cURL, as it's way more complicated than a simple file_get_contents call.
In addition to that I would look into the php.ini setting:The reason it might be failing for you is that you might have safe mode in the PHP settings.
Code: Select all
allow_url_fopen = Off- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: W3C local validation php class?
Thanks guys.
Safe mode is definitely off. But not sure about allow_url_fopen, I will check now. Nope thats not it, it is set to on
w3c allow developers to install a validation server locally, is it worth giving that a go? http://validator.w3.org/docs/devel.html
Safe mode is definitely off. But not sure about allow_url_fopen, I will check now. Nope thats not it, it is set to on
w3c allow developers to install a validation server locally, is it worth giving that a go? http://validator.w3.org/docs/devel.html