Javascript syntax highlighting not working in php files

My pages are .php files and not unusually they mostly consist of html and javascript with a little bit of php at the top.
I've noticed in these files that PHPStorm doesn't highlight javascript syntax errors. If I put the exact same code in a .html file it highlights errors as it should.
I've tried setting the php files in question as HTML in settings > template data language but it doesn't help.
I could set all the pages to have .html exts (as this the only thing that works) but then I lose my php formatting and syntax checking.
It's very annoying and makes debugging difficult. In the debugger all it tells me is "Unexpected token" and an incorrect line number.
I'm using PHPStorm 8.0.2.

This seems like a bug. How do I fix this?

Comment actions Permalink

Please provide a .php file that shows up the issue.

Comment actions Permalink
<script type="text/javascript"> if (true) } { </script>

In a php file containing just that, I get no syntax highlighting.
In a html file containing just that, I get syntax highlighting on the incorrect braces.

Simple as that.

Comment actions Permalink

It does highlight some things, but not incorrect syntax.
The main problem I'm having is when I forget to close a bracket or brace, which happens quite often when I'm writing stuff with Jquery.
When this happens it basically kills the site - and as I stated earlier - gives a pretty worthless error.
It appears I'm the only one with this problem. I tried deleting .WebIde80 and .nbi in my user folder but this didn't help.

Help please :(

Comment actions Permalink

I see, thanks for update:) Known issue - low-level error checking  done at lexer level is not available for html/javascript in PHP files. See

Comment actions Permalink

I'm quite astonished this isn't a more widely reported bug if it's been around for more than 18 months.
I've run into it so many times, so much that I just spent half a day trying to fix it.
I even tried installing NetBeans yesterday because it was bugging me so much.
Are there any temporary work arounds?


Please sign in to leave a comment.