开发者

How to creating code highlighted blocks on your website

I have written a small PHP framework and I want to make a website where I explain some basic features.

I want to display blocks of php code. Is there an easy to do this, preferably without JavaScript.

I want to have section kind of like displayed below:

// This function takes in a value and return it
public function getname($name){
  r开发者_开发百科eturn $name;
}


For the server-side there are a few options already out there:

  • The built-in highlight_file and highlight_string
  • Highlight source code in your PHP application
  • GeSHi - Generic Syntax Highlighter
  • CHIP: Code Highlighting in PHP

There are others, but just letting you know there are libraries available.


On my Tumblr blog I use Prettify for syntax highlighting. You can have a look here.

I'm really pleased with its simplicity and it support a lot of languages out of the box.


You can take a look at http://alexgorbatchev.com/wiki/SyntaxHighlighter

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜