日期:2014-05-17  浏览次数:20541 次

正则去掉<? ?>标签里的文字
curl解析某网站时,遇到一个BT的问题:某网站一段php代码由于没有使用完整的 <?php ?> 被当做html源码给解析出来了。如何用正则去掉这段php标签里的文字?谢谢。

<div id="content">
    some words
</div>
<?
$box_social['dimensioni']="80";
        $box_vota=array();
$box_vota["novideo"]='';
$box_vota["nofoto"]='';
$box_vota["id_articolo"]='1003691';
include($_SERVER['DOCUMENT_ROOT']."/incs/box_social.php");
?>
<div id="footer">
   some words
</div>

------解决方案--------------------
preg_replace('/<\?.*?\?>/','',$html);
------解决方案--------------------
 '/<\?(.+?)\?>/msi'