次のコードで、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>