源码范例:
.代码如下:
<?php
header("Content-type:text/html;charset=utf-8");
$str = ‘<script type="text/javascript" src="dd.js"></script>
测试php正则匹配掉js代码测试php正则匹配掉js代码测试php正则匹配掉js代码测试php正则匹配掉js代码测试php正则匹配掉js代码测试php正则匹配掉js代码
<script type="text/javascript" src="123.js"></script>
<script type="text/javascript">
var aa = "sdsds";
alert(aa);
</script>
测试php正则匹配掉js代码‘;
$preg = "/<script[\s\S]*?<\/script>/i";
$newstr = preg_replace($preg,"",$str,3); //第四个参数中的3表示替换3次,默认是-1,替换全部
echo $newstr;
?>