Awestruck wrote:

Thanks for pointing out that the W3C XHTML validator cannot validate files with the PHP suffix, no wonder it would not validate. Quite an oversite on W3C's part.

To repeat what Kudose said, the W3C validator does not care what extension appears in the URL, it only cares about the content of the page. The URL has nothing to do with validation. If you don't believe me, have a look at some of the pages on the W3C site and have a look at the file extensions in their URLs (incidentally, the validator's front end is itself written in Perl).

    Thank you both for being so patient.
    I am pleased to hear that W3C XHTML validator will validate a PHP file
    I always enter the URL of the php file thinking that the W3C validator is then scanning a generated page. It always complains about the Doc type and then does a report on the page but refuses to validate fully until the doctype is sorted. I enter the doctype suggested by W3c but it still refuses to fully validate. I have used every doctype possible but it still refuses. I will try your suggestion of copying and pasting from my website and then let you know what happens. I will also let you see the doctype and the resulting error message.
    Awestruck

      If it's not too private or such, a link to the problematic page in question would probably be a great boon to us helping you resolve what the problem is.

        3 years later

        I realize this is older post but for the people that still come here looking for information I will post
        I do this all the time to validate against 1.0 and 5 using the W3C tools

        1. take the completed or hopefully completed php page and put it on your server (home server or hosted deos not matter)
        2. bring up the page in several different browsers to insure that the rendered page formatting is acceptible to you in all cases
        3. when the page is the way you want it RIGHT CLICK the page in the browser and select VIEW SOURCE
        4. Copy and paste it to a text editor and save it as .html or .xhtml does not matter
        5. Go to the W3C validate page and select the validate a file option
        6. browse to where you file is and load it in and press validate
        7. correct the issues
        8. change the doctype
        9. do it again

        By doing this I can validate against 1.0 and html5 or any other doctype I want. usually I only do the 1.0 and 5

        using this process will allow you to see the direct connection of rendered php outputs and html or xhtml validation

        Have fun

          @: How is what you're suggesting any different than the way such validation has always been done?

          Client-side language validators (such as the HTML validator W3C provides) have no idea what scripting language you're using, if any. Using PHP to generate an HTML webpage is no different than using a plain .html file or even some new server-side language that hasn't even been invented yet. In the end, the client is never any wiser and simply processes whatever output it receives.

          In other words, I don't see how the process you described above is any different than before PHP was even invented; in the end, you've got some HTML/client-side language that you want client's browsers to interpretet correctly. That's it.

          In fact, W3C's validator allows you to specify a URL, so there's no need to even save the outputted HTML webpage at all.

            Agreed, and if you are concerned with render time, use the Firebug FireFox extension to see what request are taking what amount of time and if the requests are note taking the time to render the page but the application itself, look into using xhprof or another application profiling tool.

              you say the same php page validates correctly if you remove the php codes from it, am I right?

                I don't think anyone here has said that... mostly because that makes absolutely no sense?

                  I am not suggesting that this is any different than what most people do nor am I suggesting it is the only way
                  However I thought that a step sequence through the process may be helpful to some people, sorry bradgrafelman that you are not one of them

                  Not all pages are available at a URL specifically if you perform due diligence and do your testing and validating before putting a possible non validating or non working page on the web there are already to many of those.

                  I run xampp server at home and do all my validations and testing before it is ever on the web. this is why I use the file upload so that the page remains isolated until they a truely complete

                  there is always more than one way to skin a cat.

                  anoopmail I never said to remove the php tags What I said was to render the page in a browser and then save the rendered HTML SOURCE to then load up in the validator

                  For me once I have the saved rendered HTML file all I need to do is change the doctype and I can validate againt more than just one standard A URL page would need to be reloaded on the sever and simply takes more time

                  This of course is just the way I do it and I hoped it would be helpful to some that may be having problems getting it done

                  Sorry that I posted useless information bradgrafelman it will not happen again

                    FireFox + Web Developer Extension -> Tools -> Validate Local HTML = WIN

                      Write a Reply...