在以下代码中,为什么 PHP preg_match 返回 false?注意:我已经阅读了一些与我的问题标题相同但上下文不同的旧问题
<html>
<head>
</head>
<body>
<?php
$str = "This is a test for PCRE.";
$ptrn = "This";
$preg_match_result_arr;
$preg_match_result = preg_match($ptrn, $str, $preg_match_result_arr);
if (1 === $preg_match_result)
{
echo "The pattern has matched in the string:<br/>".
"the match is $preg_match_result_arr[0]<br/>";
}
elseif (0 === $preg_match_result)
{
echo "The pattern has not matched in the string:<br/>";
}
elseif (false === $preg_match_result)
{
echo "An error has occured in matching<br/>";
}
?>
</body>
</html>