ie 替换 <pre>
If you have a website that relies heavily on PRE tags, you know the important of converting PRE tag content to their HTML entities. Doing so prevents worlds of possible rendering issues. The following PHP snippet HTML-Entitizes (?) any code within PRE tags:
如果您的网站高度依赖PRE标签,则知道将PRE标签内容转换为其HTML实体的重要性。 这样做可以避免可能出现的渲染问题。 以下PHP代码段HTML会对PRE标签中的任何代码进行HTML修饰(?):
//replaces pre content with html entities
function pre_entities($matches) {
return str_replace($matches[1],htmlentities($matches[1]),$matches[0]);
}
//to html entities; assume content is in the "content" variable
$content = preg_replace_callback('/<pre.*?>(.*?)<\/pre>/imsu',pre_entities, $content);
I use this for just about every post I write. You could also stick this in your CMS if you have clients that may have use for PRE tags.
我写的几乎所有帖子都用到它。 如果您的客户可能使用PRE标签,也可以将其粘贴在CMS中。
ie 替换 <pre>