Sublime Forum

Can't set syntax to PHP

#1

Hey guys.

I cant set syntax to PHP. When I’m trying to do it, instead of PHP my syntax is set to HTML… Is this normal ? You have the same thing ?

0 Likes

#2

You are not alone, this happens for me too. It hasn’t caused me any issue though so I haven’t investigated if it can be corrected.

0 Likes

#3

I had similar problem, I installed DetectSyntax package and now all syntaxes are detected automatically :sunglasses:

0 Likes

#4

Ok i installed DetectSyntax and now i got PHP syntax but when i select HTML syntax i got PHP syntax now so now is the opposite… You got the same situation @**evenous ** ?
This is weird because in work i can select PHP syntax from menu and it works correctly in work but in home its not. There are lots of bugs on windows systems… Not all shortcuts works, on some machines works on some not. This should be corrected in sublime text 2.

0 Likes

#5

@yuucOm

Create an issue on GitHub [1] and either paste or gist the file you are having problems with and I’ll investigate. Also note in the issue if you added any of your own rules for DetectSyntax or if you were using all the defaults. And if you did add your own, be sure to include those as well.

[1] github.com/phillipkoebbe/DetectSyntax/issues

0 Likes

#6

I have the same problem… Any help?

0 Likes

#7

I’m was having the same general issue with Sublime Text 3. It was all working fine earlier today, then suddenly all HTML documents have no syntax highlighting. When I set the syntax to HTML it shows HTML as checked in the selection list, but the active syntax in the bottom right of the editor shows up as PHP. (and no functioning syntax highlighting)

In my case PHP files also show up with PHP as the selected syntax highlighting, but syntax highlighting does not work.

I did notice that the AngularJS package adds “HTML (Angular.js)” as a syntax highlighting option, which when selected was working just fine. As I installed that package yesterday I thought it may be the culprit, but after uninstalling it the issue persisted. After re-installing the AngularJS package the “HTML (Angular.js)” syntax highlighting no-longer works, and PHP is shown as the active syntax in the bottom right of the editor.

Initially restarting Sublime did not appear to resolve this issue, but a recent restart of the application appears to have (at least temporarily) resolved the issue. I’m still posting this here just in case some of this information helps address this bug, which appears to have been around for a while.

0 Likes

#8

Having the same issue with PHP being marked as PHP in the list of languages, but when I release the selection it shows HTML in the bottom/right corner and the syntax is highlighted accordingly.

Is there any easy solution for that yet!?

There is also a closed, but unanswered post on stackoverflow: stackoverflow.com/questions/1675 … g-problems

:arrow_right: Build 3065 on Mac OS 10.9

0 Likes

#9

The HTML syntax actually opens certain types of what are generally considered to be php files e.g. phtml, inc, tmpl, tpl. The PHP syntax i.e. source.php is a subset of the HTML syntax.

The syntaxes are based on a very old version of the Textmate PHP Bundle. In fact it’s based on version from around Feb 2 2012. It’s old.

The newer version of Textmate PHP Bundle makes the above file types like phtml full fledged PHP syntax language types. I’ve tried to figure out how best to do this with a custom PHP Grammar (shameless plug). The problem is that the HTML syntax is tied to the PHP syntax it’s not just a case of adding the above file types to the syntax definition file types list. Also, it’s not neccessarily just a case of converting the existing textmate bundle into a sublime text one because there are dependency issues with other packages.

Toubleshooting

Make sure you try clearing any sublime text caches and indexes. If you’re on Ubuntu check out:

Sublime Text 3: ~/.config/sublime-text-3/Cache and ~/.config/sublime-text-3/Index

I don’t know about Sublime Text 2.

0 Likes

#10

I observe the very same problem in build 3103.
Only that one php file shows the right php syntax highlighting, while another shows html colors in spite of having set the language explicitly to php and php shown in the language field down right.

0 Likes