views:

80

answers:

6

Hi,

I'm new at web development, so to make sure I'm writing good code I've been using w3.org validation tools. I'm currently working on a project where I generate a lot of my html with php functions, and I'd like to validate the html, but w3.org doesn't support that. The only way I've found to do it is to render my code, view source and validate that, but that's an awkward, time consuming process, that only approximates validation as it renders differently in different situations. Any suggestions?

Thanks,

Rebecca

+4  A: 

Tidy Project:

http://tidy.sourceforge.net/

http://www.w3.org/People/Raggett/tidy/

Good luck.

Edit -

To be clear, with Tidy you can be reasonably certain that the output of your script is valid against a given standard.

Ian P
I would add that you could also use output buffering to catch your scripts output and then validate it against tidy : http://php.net/manual/en/book.outcontrol.php
MaxiWheat
+3  A: 

You can use Html Validator add-on for FireFox.

çağdaş
A: 

The validator tools will not care about php, so if your php is 'bad', it won't care. It only checks html for concision and proper nesting to the doctype.

CodeJoust
A: 

The various developer tools in the major browsers will help you validate the HTML your script emits.

  • IE6/7 - you can install the IE Developer's Toolbar
  • IE8 has the toolbar built in
  • FireFox - you can get the Web Developer Toolbar as an addin

I think Opera has some tools built in as well, but quite frankly I only use Opera for testing after I've built using Fx and IE.

AnonJr
A: 

Try this, Web Developer 1.1.8 toolbar.

This ad-don works superbly, you can validate locally, for example:

Validate Local CSS

Validate Local HTLM

if you don't have access to some external web-server or even if you do have access to it.

In addition the installation is easy and to validate a given page all you have to do is right click on Tools and there is a whole array of validation options.

https://addons.mozilla.org/en-US/firefox/addon/60

Newb
A: 

Alternative approach: Hitchhike direct-input at the W3C validator:

( I am also facing the problem, that my staging server would need to be online, to allow for an easy validate-here link... )

The direct input at the w3c validator submits a form. Or in other words: The actual validation-page receives a POST request.

So how about: Make a link (i.e. in your footer) that leads to a submitForValidation.php In that php file:

  • grab the Referer-URL you just came from (through your localhost server)
  • submit as POST to the W3C page

Not done it yet, but will probably implement that soon.

Fronker