我想在文本区域显示一个代码片段,以便轻松剪切和粘贴,如何?

I am generating a bit of code to display a picture as a link (frex <a href="site.com"><img src="/image.gif"></a>) I would like to show how it look, but also in a textbox adjacent show the actual code. Is there a function in PHP that will automagically escape HTML code so it can be displayed?

print "<textarea>" . htmlspecialchars($html) . "</textarea>";

Here you can find details about htmlspecialchars from official documentation.