W3C validation and PHP

Community Beginner ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

I have a website that uses HTML5 and PHP.  I use DW 21. 

When I submit the pages to W3C validation, any page with a <?PHP> tag on it generates a validation error.


For example, this line <?php if (!isset($_SESSION)) { session_start(); } ?> generates this validation error:

Error       C:\xampp\htdocs\Partnership\index.php Saw <? . Probable cause: Attempt to use an XML processing instruction in HTML. (XML processing instructions are not supported in HTML.)      2

 

I'm sure this is because the php commands have not been stripped out before it gets to the validator.  Is there a way to avoid these errors?

Views

240

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Dec 01, 2020 Dec 01, 2020

1. In Dreamweaver CC 21.0, switch to Live Code from the View menu.

2. Go to Window > Results > Validation.

3. In the Validation panel, click the white triangle and select Live Document.  See screenshot.

 

image.png

 

NOTE:  I have a local testing server defined in my site settings so I can parse PHP files locally.

 

 

 

Likes

Translate

Translate
Adobe Community Professional ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

In order to validate your pages you should validate the code that is generated from a server (testing or live) which won't contain PHP as that would have been processed.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

1. In Dreamweaver CC 21.0, switch to Live Code from the View menu.

2. Go to Window > Results > Validation.

3. In the Validation panel, click the white triangle and select Live Document.  See screenshot.

 

image.png

 

NOTE:  I have a local testing server defined in my site settings so I can parse PHP files locally.

 

 

 

Nancy O'Shea, Adobe Product User & Community Professional
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

OP does have a local testing server installed:

 

C:\xampp\htdocs\Partnership\index.php

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

You should not be getting that error as you are processing the php though XAMPP. Sounds as though your testing server is NOT parsing the php code.

 

Does this happen wherever you insert php code in your page - the specific line you posted as an example should go before the <!DOCTYPE html> tag but if you are getting the same error for other php code inserted within the html then something is wrong.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

"You should not be getting that error as you are processing the php though XAMPP."

Not quite true.

 

1. Copying and pasting PHP code from DW into the online HTML5 validation service will produce validation errors.  That's expected.

 

2. Checking PHP code in DW will also produce validation errors unless one switches to Live Code and validates the Live Document.   IIRC, these features didn't exist until Creative Cloud.

 

Nancy O'Shea, Adobe Product User & Community Professional
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 02, 2020 Dec 02, 2020

Copy link to clipboard

Copied

Well it looks to me like the OP IS processing their page via XAMPP from their post. They are definitely NOT pasting code into the online validator because it wouldn't return this -  C:\xampp\htdocs\Partnership\index.php

 

I dont know how Dreamweaver handles the request through XAMPP (in this view or that view) but in normal circumstances the parsing error shouldn't occur, so something isnt quite right. Either the server is not parsing the php or Dreamweaver is not set up correctly to parse the code.

 

At this stage, if none of the suggestions posted, work, I would just try another web editor to test the set up. If the same issue occurs then its a server issue, if it parses then its a Dreamweaver issue.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 01, 2020 Dec 01, 2020

Copy link to clipboard

Copied

Sounds like PHP is not being parsed or you are submitting raw code to the validator. Are you copy and pasting code into the validator or a URL?

Paul-M, ACP

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Dec 02, 2020 Dec 02, 2020

Copy link to clipboard

Copied

To correctly validate a .php page from Dreamweaver...

1. Make sure your local server is running
2. Open the .php page in DW. If the page is open first, the correct option for validating will be grayed out
3. Open the Validation window under Window > Results > Validation if it's not already
4. Click the Reports button (play arrow icon) in the upper left of the Validation window and choose "Live Document (W3C)". Oddly, this option will be grayed out if you click it while DW doesn't have your systems focus (say, while bouncing back and forth from a web browser while typing a forum post, LOL). Turning on Live Code in the View menu is not necessary.


That should do it.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 02, 2020 Dec 02, 2020

Copy link to clipboard

Copied

LATEST

Thanks Nancy.  That works like a charm.  I started using DW long before live view came along; hadn't paid much attention to it.  Thanks again.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines