我正在构建一个在线片段管理网站,是否有一个控件可以用来根据语言可视化代码和颜色代码源?

You guys know in Pastebin how according to the selected language, the code is colored?

Is there a control I can use on my site? I'm using PHP and Zend Framework.

Edit: I was thinking something along the lines of:

CodeControl mycontrol = new CodeControl(sourcecode.txt, 'c#');

or

CodeControl mycontrol = new CodeControl(sourcecode.txt, 'javascript');

I'm sure someone already has done this, no point in reinventing the wheel. :)

You can use PHP's highlight_string function for that. You can also use Prettify the code colorizer that StackOverflow uses.

There's a builtin function - highlight_string() but it only really deals with PHP source. You might want to try GeSHi which supports lots of langs.

C.