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

Go To


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?

2012-04-04 03:19
by JW.


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

2012-04-07 21:47
by casperua
Thanks. That seemed to work for me. (Although I have messed around with the settings so much that I cannot confirm if this is the only change that you need to do to make it work.) It makes sense though - JW. 2012-04-08 00:27
Works perfectly. thanks - Matt Setter 2013-02-27 08:53