Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPStorm - Javascript syntax highlighting not working in php files

The files in question are .php and not unusually they mostly consist of html and javascript with a little bit of php at the top. I've noticed that PHPStorm doesn't highlight javascript syntax errors in php files. 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. I'm using PHPStorm 8.0.2. This seems like a bug. How do I fix this?

like image 399
hedgehog90 Avatar asked Oct 12 '25 01:10

hedgehog90


1 Answers

Save the file as .php and then specify JavaScript as a secondary language by going to Settings >> Template Data Languages

Syntax highlighting of PHP inside JavaScript (and other languages)

like image 200
Brock Amhurst Avatar answered Oct 14 '25 16:10

Brock Amhurst