Validation

N

Nico Schuyt

darren said:
What is the best way to validate HTML produced by PHP?
I have been "viewing source" and copying and pasting into the code
checker at http://validator.w3.org/

That's one solution. The other is to use the URL from the page on a (remote)
server. AFAIK there's no program that can validate PHP-pages on local host.
 
O

Oli Filth

Nico Schuyt said the following on 05/01/2006 13:32:
That's one solution. The other is to use the URL from the page on a (remote)
server. AFAIK there's no program that can validate PHP-pages on local host.

There's always the Tidy/HTML Validation extension for Firefox...
 
D

darren

Should also have mentioned that the site is a members only site, so the
validator gets refused entry.
 
E

Els

darren said:
Should also have mentioned that the site is a members only site, so the
validator gets refused entry.

You can give the validator a password I thought?
 
C

cwdjrxyz

darren said:
Hi Folks,

What is the best way to validate HTML produced by PHP?

I have been "viewing source" and copying and pasting into the code
checker at http://validator.w3.org/

I always use the w3c validator that you mention. If the page validates,
you also are given the option to validate the CSS if you wish.

You have to be very careful in validation of a php page, because php
sometimes is designed to give different results for browsers that
handle things in different ways. Thus you get different source code on
different browsers. For example, I am now serving many of my pages as
xhtml 1.1 using the correct mime type application/xhtml+xml. The recent
Mozilla family(Firefox,Netscape,Mozilla) and Opera browsers can handle
the code served with this correct mime type, but IE and some earlier
browsers can not. Hence I write a php include at the very top of the
page that sees if the viewing browser will accept true xhtml served
with the correct mime type. If it can, all of the page above the head
tag is written in xhtml 1.1 and served with the correct mime type. If
it can not, the code above the head is written as html 4.01 strict and
<br /> etc is converted to <br> etc required for xhtml, using regular
expressions. Also a comment is written in the source code for html 4.01
saying that the code has been converted to html 4.01 because the
browser is out of date and can not support true xhtml 1.1 served
correctly. The php include code also forces the w3c validator, when you
input a URL, to validate the php page as true xhtml 1.1(the validator
contacts the php page for validation directly, and not through your
browser). To validate the source code for the xhtml or html page served
to your browser, you have to right click while on the page, copy the
source, and paste it in the text box at the w3c validator. To see an
example of this, go to my page at
http://www.cwdjr.info/media/playersRoot.php .If you use a recent
Mozilla family browser, when you right click and select to show source,
you will find xhtml 1.1 code. If you use an IE6 browser, you will find
html 4.01 strict code. In this case it is always important to validate
the html 4.01 strict code to make certain the automatic php conversion
from xhtml 1.1 to html 4.01 strict was done properly. If you use the
extended interface at the validator, it will tell you the mime type
used to serve the page, and it is application/xhtml+xml if you serve
xhtml 1.1 correctly. Many write xhtml pages and serve them as html. You
have to have the correct mime types for xhtml on the server, and you
use a php approach such as I used if you want to handle IE6 and such,
or you use a .xhtml or .xml extension(with mime types for these
installed on the server) if you are only interested in browsers that
can handle true xhtml.

______________________________________________________________________

Due to increased spam, my new spamtrap1 address is set up only for NGs
and all mail to it gets dumped into a junk mail folder every day and
soon is automatically deleted This address will be changed as spam to
it increases. I try to view the junk mail file every day, but I
sometimes miss.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top