I’m using Eclipse to write php and naturally I get color coding like all IDEs do.
How do I get the same effect in a blog?
See this example (scroll down to see the code colors), he has full colors, green, red, blue, pretty acceptable I’d say
http://www.tellinya.com/read/2007/06/15/20.html
Is there something that’s standalone PHP that can achieve this, or do I need a plugin and install a CMS? I’d prefer standalone I guess if possible.
You can use SyntaxHighlighter, which is a purely JavaScript solution. Or see 9 Useful Javascript Syntax Highlighting Scripts for more.
If you want to generate the highlighting on the server side, you can use the PHP library GeSHi. There is also a Drupal plugin that acts as an output filter.
In the example you’ve shown, the author is encapsulating the code snippet among
<code></code>
tags to preserve indentation and he’s using style information to set the colors.You could probably use some javascript code to enable “syntax highlighting” for PHP that is what you want.
You might want to have a look, for example, to:
http://softwaremaniacs.org/soft/highlight/en/
For drupal use GeSHi Filter for syntax highlighting module…
You can embed Pastie snippets where ever you want, with JavaScript.
They’ve got a blog post on it. I love it!
For WordPress, you can use the http://wordpress.org/extend/plugins/wp-syntax/ plugin. If you just need something basic for PHP only, you can use the native http://php.net/highlight_string function.