我写了下面的代码(它确实可以工作),想知道为什么在模式内部不需要转义'<'和'>'字符,因为它们在php手册中被认为是“特殊”字符。
http://www.php.net/manual/en/function.preg-quote.php
var_dump(preg_match('/<[A-Za-z][A-Za-z0-9]*>/', "<html>", $matches));
echo "<pre>";
var_dump(htmlentities($matches[0]));
echo "</pre>";
输出:
int(1)
string(12) "<html>"