Maison >développement back-end >tutoriel php >PHP中怎么转义,大拿请帮忙!

PHP中怎么转义,大拿请帮忙!

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBoriginal
2016-06-13 11:55:03879parcourir

PHP中如何转义,大拿请帮忙!!!急急急!!!
以下new_content是mysql中使用select返回的内容

<br />$new_content='<P>下面我给大家讲讲javascript函数:</P><PRE class=js name="code"><script> <BR>function show() <BR>{ <BR>alert("hello world"); <BR>} <BR></script>
 

 结果如图:
PHP中怎么转义,大拿请帮忙!

';

请问如何将其中的<script>和</script>转换成3f1c4e4b6b16bbbd69b2ee476dc4f83a和2cacc6d41bbb37262a98f745aa00fbf0
------解决方案--------------------
htmlspecialchars这个函数可以转义
------解决方案--------------------
$new_content='<P>下面我给大家讲讲javascript函数:</P><PRE class=js name="code"><script> <BR>function show() <BR>{ <BR>alert("hello world"); <BR>} <BR></script>
 

 结果如图:
PHP中怎么转义,大拿请帮忙!

';
var_dump(preg_replace_callback('//i', function($r){return htmlentities($r[0]);}, $new_content)) ;
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn