Sublime Forum

PHP syntax highlighting variables within double quotes

#1

I have been using atom for a long time and recently made the switch to ST3 because of performance . There seems to be an issue with the highlighting of variables with single quotes withing double quotes.

$pdo->query("SELECT * FROM members WHERE ID = '$customer'");

In the above example $customer is not highlighted as a variable in ST3 as opposed to Atom.

Any suggestions on how the fix this?

0 Likes

#2

what color scheme are you using? it is highlighted correctly for me using my own color scheme :slight_smile:
if you know how color schemes work, basically the color scheme needs to target variable.other (and/or something like string variable if you want different coloring of variables inside strings compared to outside) - if it doesn’t then the string coloring takes effect

0 Likes

#3

As an aside, is this vulnerable to SQL injection?

1 Like

#4

Thats a great question. Normally this would be subject to injection without other checks. Ideally one would want to bind the parameters. But in this particular case there is no user input. :slight_smile:

kingkeith
Can you please point me in the right direction to edit the correct files. I am new to ST.

0 Likes

#5

Documentation on color schemes is here:
http://www.sublimetext.com/docs/3/color_schemes.html

How to edit them:

  1. Install PackageResourceViewer via Package Control
  2. Open Command Palette
  3. Select PackageResourceViewer: Open Resource
  4. Select the package containing your color scheme - if you haven’t changed it from the default, it will be Color Scheme - Default
  5. Select the .tmTheme file you are using - if you haven’t changed it from the default, it will be Monokai.tmTheme
  6. Edit away, using the docs as a reference
  7. Save it
  8. See that the colors have changed in your PHP document
  9. Install OverrideAudit so that you’ll know if/when the maintainer of the color scheme you have overridden makes some changes and what the differences are
0 Likes

#6

Wow! That did the trick. Thank you so much. You do need to target variable.other. I added the block and now its clear.

1 Like