请帮助尝试所有方法,没有任何效果。我正在使用PHP 7向MySQL DB插入一些代码,然后插入代码,这一切都很好;因此:Eg:<p>Hello:<b>Amber</b>\r\n<div>\r\n<hr>\r\n\r\n<button onclick=\"insertTextAtCursor()\">Lisa sisend</button>当我在HTML中使用PHP调用记录集时,由于HTML代码被隐藏,因此不会显示任何内容。我需要以纯文本形式显示HTML代码,但“不显示\r\n显示换行符” - 格式化;因此:Eg:<p>Hello:<b>Amber</b><div><hr><button onclick=\"insertTextAtCursor()\">Lisa sisend</button>纯css和javascrpt代码在这个PHP行中很好地显示出来,但不是HTML:$author_code1 = null;$author_code1 = $row["author_code1"]; $author_code1 = str_replace('\r\n', '<br />', $row['author_code1']);echo $author_code1; 更接近它,因此添加:<?phpecho "<xmp>";echo str_replace("\r\n", "<br/>", $author_code1);echo "</xmp>";?> 这在一行中显示所有内容:</html>\r\n </textarea>\r\n</div>\r\n </div>\r\n</section>\r\n<button>Lisa send</button> 我的问题是为什么它没有突破到下一行?喜欢:<div><p>Hello:<b>Amber</b></p></div><hr> <button>Lisa send</button>请帮忙。
1 回答

陪伴而非守候
TA贡献1757条经验 获得超8个赞
我认为它在很大程度上提供了答案。许多人只是回复,有些复制粘贴。但是,我找到了一个解决方案:
$author_code1 = null;
$author_code1 = $row["author_code1"];
$author_code1 = str_replace('\r\n','', $author_code1);
$author_code1 = str_replace('<',"<", $author_code1);
$author_code1 = str_replace('>',">", $author_code1);
$author_code1 = str_replace('</',"</", $author_code1);
<pre>
<code class="html hljs">
<!-- my db code -->
<?php echo $author_code1; ?>
<!-- my db code -->
</code>
</pre>
- 1 回答
- 0 关注
- 91 浏览
添加回答
举报
0/150
提交
取消