开发者

PHP web-textbox syntax highlighting

开发者 https://www.devze.com 2022-12-12 05:47 出处:网络
I\'m looking for a solution where users can copy/p开发者_StackOverflowaste PHP code into a textbox and it will be highlighted like it is inside an IDE. (Like stackoverflow does when you paste a code s

I'm looking for a solution where users can copy/p开发者_StackOverflowaste PHP code into a textbox and it will be highlighted like it is inside an IDE. (Like stackoverflow does when you paste a code snippet) Any links/ideas/more information would be appreciated.


Check out GeSHi. It does almost everything for you.


You can use PHP's highlight_string

Very simple example...

<form action="" method="post">
<textarea name="str"></textarea>
<input type="submit">
</form>
<?php
highlight_string($_POST['str']);
?>


http://phpanywhere.net/


Two sites that I use are gist.github.com and codepad.org. You might want to check out what libraries they're using, or just take advantage of their sites and avoid the work yourself by linking through to 'em.

0

精彩评论

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