Page 1 of 1

PHP Syntax Highligting

Posted: Tue Jan 20, 2004 5:57 pm
by Jesus_H_Christ
As languages get goofier syntax highlighting needs to be improved.

The syntax highlighting support in TextPad is a bit clownin' and there is one major thing, and a minor thing that has gotz to be changed.

[major] Support for Heredoc strings (<<<EOT)
http://www.php.net/manual/en/language.t ... ax.heredoc

When I use Heredoc strings in my PHP scripts it will totally face up the syntax highlighting. I tried to set <<<EOT and EOT; in the syntax file instead of " but it didn't work.

[minor] Support for funny strings: print "PHP Action {$_GET['junk']}";

It would be nice if Textpad could highlight that expression properly.

Posted: Thu Jan 22, 2004 10:37 am
by ramonsky
Actually, this is a very good point. In PHP (and also in many Unix shells) a string such as "x = $x" isn't actutually a constant! Why not? Because the $x inside the quote marks is expanded at the point of execution, and not before. So, if you were to highlight it to reflect actual usage it would be something like:

" x = $x"

The somewhat more complex examples of Jesus H Christ (nice name by the way 8) ) would require even more complex coloring, but the trick really is to know exactly what is "escaped" and what isn't when inside quotes.

It's interesting to consider that I actually modify the way that I write PHP in order to get the colors right! That is, I would tend, instead of writing:

Code: Select all

print "PHP Action {$_GET['junk']}"; 
to write

Code: Select all

echo "PHP Action ", $_GET['junk'];
because that way it gets the colors right. Hmmm....