剥离不完整的HTML标记

时间:2014-11-21 14:56:47

标签: php html mysql pdo

我正在使用php pdo,mysql开发博客,我正在使用CKEditor。如果我选择使用'来源'来撰写博文。 CKEditor中提供的选项,只需直接编写HTML代码而无需使用编辑器。

我遇到了这个问题,如果用户错误地写了一个不完整的html代码,例如用户忘记关闭div或span,它会反映整个网站并且布局正在改变。如果用户在编辑器中编写不完整的html代码,就不会像wordpress那样反映网站,是否有任何解决方案。

错误代码的示例

<p style="text-align: center;"><span style="color: #0000ff;">List of Links.</span></p>
<p style="text-align: center;"><span style="color: #ff0000;"><strong><a class="lbp_secondary" style="color: #ff0000;" href="http://google.com" target="_blank">Click here for Google</a></strong></span></p>
<p style="text-align: center;"><span style="color: #ff0000;"><strong><a class="lbp_secondary" style="color: #f

请帮帮我

1 个答案:

答案 0 :(得分:0)

统计所有<.*>代码和</.*>代码(使用preg_match个功能)。如果它们不是相同的条形标签

相关问题