0
4

3 回答 3

0

Sanitize it on the way in. Then you only have ONE chance to screw it up and get your site hacked, instead of having to get it right everywhere you use the data.

于 2012-08-13T19:29:36.927 回答
0

I think you probably want to parse the HTML with DOM, then find all instances where there's code between <pre> and <code> tags.

Then you can take that text and do a str_replace() on it.

于 2012-08-13T19:31:22.373 回答
-1
$data = 'one<pre><code>two</code></pre>three';
$code = preg_match('~^(.*)<pre><code>(.*)</code></pre>(.*)$~', $data, $matches);
var_dump($matches);
于 2012-08-13T19:30:42.247 回答