PHP support with HTML -annoying highlight bug when using quotes

19 views
Skip to first unread message

Nick Mok

unread,
Jan 8, 2013, 8:14:06 PM1/8/13
to intype...@googlegroups.com
Hi I noticed when editing a php file in language mode: PHP - that php gets a little confused when writing words with apostrophes. 

When writing just html (No php at all) in a .php file in the php language mode which single quotes like so: 
isn't 
hasn't
john's 

php thinks you are opening quotes for an echo statement, or string assignment: echo 'blah blah' or $var = 'String'

php automatically opens 2 single quotes (which is fine) but if you try remove on all of the text after the first quote highlights as green, Until/unless you close the single quote off. 

Now this is quite annoying, meaning I have to switch between html mode and php. And when writing in php, all of my code beyond the point is highlighted. So any php syntax highlighting is rendered as green. 

Please make a fix which does not confuse php's functionality with html. Is it possible to make it so php's highlight functionality only occurs within php tags.


Cheers,

Nick

Martin "Cohen" Balazik

unread,
Jan 9, 2013, 5:28:21 AM1/9/13
to intype...@googlegroups.com
tl;dr: Always use "HTML" grammar for writing PHP.

PHP was designed as a templating language which requires <?php token to switch to actual PHP code from a root language (which is usually HTML). Therefore you should choose "HTML" as the primary grammar for PHP code. HTML itself handles a <?php token and transitions to PHP language.
--
Martin "Cohen" Balážik

Nick Mok

unread,
Jan 9, 2013, 6:42:36 AM1/9/13
to intype...@googlegroups.com
Ah yes you are correct! Thanks very much!

Martin "Cohen" Balazik

unread,
Jan 9, 2013, 8:49:10 AM1/9/13
to intype...@googlegroups.com
You are welcome.
--
Martin "Cohen" Balážik
Reply all
Reply to author
Forward
0 new messages