Sublime Forum

Syntax Highlighting Issue With .PHP

#1

I have a problem that I am not sure how to fix.

I have code that when on its own in an unsaved file or as an .HTML file, will highlight correctly:

But when the same code is inside a .PHP file, will lose all of the highlighting:

It doesn’t seem to matter which color scheme I use, which leads me to believe it is syntax highlighting issue with .PHP.

Is there a way to fix this??

Thanks!!

0 Likes

#2

The reason is quite simple I believe. When you set the syntax highlighting to HTML it is looking out for HTML looking stuff and highlights accordinglly.

When you use PHP syntax highlighting it is looking out for PHP stuff, not HTML. So if it finds a huge string like that it’ll just see it as a string and highlight it accordingly.

  • Eduan
0 Likes

#3

Well, if I change the syntax on the .PHP file with no highlighting, and change it to HTML, there is still no highlighting in that piece of code.

If I change the syntax to pretty much anything other than HTML or PHP the code will actually highlight though the highlighting is a bit wonky since it is for a different language.

0 Likes

#4

The reason the HTML syntax doesn’t highlight that file is because it’s inside that huge string. If you take it out of that string does it recognize it? If it does then it means HTML is just confused as to those three quotes (""") and doesn’t know what to make out of them.

0 Likes

#5

The first picture is just the list pasted into it, it highlights fine.

Its only when its sandwiched inside of PHP, that it loses all highlighting.

0 Likes

#6

Perhaps it’ll help to take a look at the highlighting for MySQL?
I remember that sql queries are highlighted inside PHP Strings. So try the same for HTML inside PHP Strings.

I don’t know if this works or where to find this. But perhaps it’ll help you.

0 Likes