scriptygoddess

15 Apr, 2004

PHP Syntax Coloring

Posted by: Jennifer In: Bookmarks

I've been fiddling with a syntax coloring hack for PHP that makes use of PHP's highlight_string function. Coupled with an upload script, it can highlight a file and stick it in a div that you can paste into a page.

The clever part was figuring out how to make the resulting code valid, as well as getting rid of non-breaking spaces (which turn into nasty invisible script-breaking beasts when you copy and paste from the browser). Just to be clear, 99% of the cleverness on my part was obtained from reading through the PHP.net user comments and public CVS.

Anyhow, here it is:
http://www.metalgeek.com/archives/2004/03/30/000018.php. And there's a link to the source as well, which shows you what it does.

I'd be interested to know if anybody finds it useful, or has any helpful comments. It would also be pretty cool to turn it into an MT plugin, but I can't quite grasp the syntax yet.

No Responses to "PHP Syntax Coloring"

Comments are closed.

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements