Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell Eclipse to validate HTML files as PHP?

I have just started using Eclipse PDT, and I have a similar problem to that which is described in How do I suppress warnings in Eclipse for PHP?

I have just pointed Eclipse to look at a project that was built with a different IDE. In that project there are many HTML files that are parsed as PHP by Apache.

I am getting many Eclipse validation errors showing up in my Problems Window.

However, I suspect that the only reason why Eclipse thinks that they are errors is because it is thinking that those files are HTML. They do have the .html extension after all. Bless it.

I am reluctant to change the validation settings to suppress the errors, because it seems like it is not really tackling the issue, but just putting a plaster over it.

I have already followed the suggestion here and drilled down to General -> Editors -> File Associations and associated PHP editor to be the default editor associated with .htm and .html file extensions. (And then restarted Eclipse). But, that has had no effect.

So I'd appreciate it if someone could let me know how to tell Eclipse to validate .htm files as PHP.

Also, just for interest, which piece of the Eclipse framework is responsible doing the actual validation?

like image 835
JW. Avatar asked Oct 08 '22 05:10

JW.


1 Answers

You should go to in your eclipse preferences to General -> Editors -> File Associations as you did and then click on "Content Types":

enter image description here

and add *.htm as PHP Content Type

enter image description here

P.S. The method works for Eclipse 3.7.2

like image 145
casperua Avatar answered Oct 12 '22 20:10

casperua