简体   繁体   English

我想在文本区域中显示一个代码片段,以便可以轻松地剪切和粘贴它,怎么办?

[英]I would like to display a code snippet in a text area so it can easily be cut and pasted, how?

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. 我正在生成一些代码以将图片显示为链接(frex <a href="site.com"><img src="/image.gif"></a> ),我想展示它的外观,还可以在相邻的文本框中显示实际代码。 Is there a function in PHP that will automagically escape HTML code so it can be displayed? PHP中是否有一个可以自动转义HTML代码以便可以显示的函数?

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

在这里,您可以从官方文档中找到有关htmlspecialchars的详细信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的php代码中有一个mysql查询,该查询被剪切并粘贴在两个地方。 我如何才能将它放在一个地方? - I have a mysql query in my php code that is cut and pasted in two places. How can I get it to be in one place? 如何在可编辑文本区域显示内容? - how can i display content in editable text area? 如何从文本区域获取显示为原始输入的文本 - How to get text to display like orginal input from text area 我想知道如何在一个单词之后做标签空间,以便之后出现的模式将彼此对齐 - I would like to know how can i do tab spaces after a word so that the pattern that comes after that would be align with each other 我将如何更改此小片段,以便与oreg_replace一起使用 - How would I change this small snippet so it works with oreg_replace 我想将代码字符串替换为PHP文本中的预代码 - I would like to replace code strings to pre code in text in PHP PHP如何在刚插入数据库的文本区域中显示文本? - PHP How can I display text in a text area that I just inserted to my database? 如何组织laravel项目的github存储库,以便用户轻松安装和运行它? - How can I organize my laravel project's github repository so that users can easily install and run it? 如何在 HTML 片段中找到文本节点? - How can I find text nodes in an HTML snippet? 如何优化此代码段以更快地执行并占用更小的空间? - How can I optimize this code snippet to execute faster and with a smaller footprint?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM