Article

2 Quick PHP Tips

Page: 1 2

Bonus Tip!

Getting Syntax Highlighting for PHP with Dreamweaver 4

As I was programming in PHP using Dreamweaver 4 as my text editor, I came across a handy little trick. You can fool Dreamweaver into thinking that code on the page is JavaScript, so that it applies the same syntax highlighting rules to your PHP as it would to JavaScript.

JavaScript and PHP both draw from the same languages, including C and Java, and therefore have many aspects in common. Try it out and see for yourself. Add this code to the top of a PHP document, open it in Dreamweaver 4, and go to the text editor (you can click Ctrl-Tab on your keyboard to switch views):

/* >The code to get PHP syntax highlighting with Dreamweaver
<script language="JavaScript"> (courtesy of david@superupdate.com) */

What the code does is close out the most recent left bracket on the page (typically from <?php) and sets the script language to JavaScript for the remainder of the page. The code itself doesn’t affect PHP because it is commented out using the /*…*/ commenting system.

I hope these little PHP coding tips make your development time more efficient, and your resulting code more effective!

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links

Rate This Article

  • 1
    Poor
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
    Great

Comment on This Article

Have something to say?

Post A Comment

You need to be a member of the SitePoint Forums to comment on this post. Sign Up

Already a member? Post using your SitePoint Forums account: