用实体引用(entity reference)
$a='<a onclick="if(a &gt; b) alert(111)">xx</a>';

解决方案 »

  1.   

    想不出来 楼上的 if(b<a) 测试后结果也不对
      

  2.   

    $a='<a onclick="if(a>b) alert(111)">xx</a>';
    preg_match("/.+/", $a, $matches);
      

  3.   

    $a='<a onclick="if(a>b) alert(111)">xx"x"x</a>';
    preg_match("/<([a-z]+).+>(.+)<\/\\1>/", $a, $matches);
    echo "<pre>";
    print_r($matches);
      

  4.   

    呵呵,先留一个脚印。
    记得在php.net手册的讨论上有过类似的例子。
      

  5.   

    改成
    <script language="javascript">
    if((a-b) !== Math.abs(a-b)){
    alert(111)
    }
    </script>
    试试
      

  6.   

    $a='<a onclick="if((a-b) !== Math.abs(a-b)) alert(111)">xx</a>';
    echo strip_tags($a);
    ?>
      

  7.   

    sdpong(耶和华)显然不知道楼主要做什么!!以为是语法问题!用strip_tags也好,用正则也罢
    对 $a='<a onclick="if(a>b) alert(111)">xx"x"x</a>';
    都作非贪婪匹配
    遇到 if(a>
    就当做匹配了一个标签
    按照 ashchen(輝輝) 说的
    先想办法匹配属性,再匹配标签就容易了