Sublime Forum

Strange PHP syntax highlighting within quotations

#1

Hello,
I am new user of ST3. PHP syntaxhiglignting behaves strange.
1st problem is how to highlight variables within double quotation… it’s not highlighting at all. (I have really tried to find anything about that here in the forum but no success)
2nd problem is when string starts with SELECT/ INSERT etc. When it’s at the next line, its ok, but if it’s in the same line as opening quotation mark, the word is highlighed (is should not), fllowing character # starts comment (it should not).

It’s new sublime installation. I have tried to install many packages or color schemes but nothing works.
Do must I edit somehow the slope definitions (how and where?) or is there any HOWTO?

Many thanks
David

0 Likes

#2

For the bug with $variable inside the string, please post an issue at https://github.com/sublimehq/Packages/issues with a copy of the source code. That way we can ensure it gets looked into and possibly fixed.

The second example is working as intended. It detected that you embedded SQL in a string, so it highlighted the SQL for you. If you do not want that to happen, you would need to find an alternative definition for PHP, or create a copy of the default one and edit it to remove the SQL highlighting feature.

0 Likes

#3

Very thanks for the reply. Both of the issues I have solved. (It’s not the problem to post it as bug).
ad 1) As I have found in another posts, it’s the problem based on default Color scheme monokai. The scope is ok, but the color of variable in default color scheme is not defined. So it’s just about change/modify color scheme.
ad 2) the basic problem is based on the CMS, I have used. It uses the character # as default db prefix (to be replaces later). The solution wich works for me.
Very good info is here:
https://packagecontrol.io/docs/customizing_packages
the steps are:
i) copy the package /opt/sublime_text/Packages/PHP.sublime-package into temporary directory
ii) rename to PHP.zip
iii) unzip PHP.zip
iv) - edit PHP Source.sublime-syntax
v) to disable comments starting by # comment lines:
- match: '#(\\"|[^"])*(?="|$\n?)' scope: comment.line.number-sign.sql
in the section sql-string-double-quoted

  • to disable highligting SQL within double quotes at all comment line:
    - include: sql-string-double-quoted
    vi) copy this file into ~/.config/sublime-text-3/Packages/PHP/PHP Source.sublime-syntax

David

0 Likes