<?php$subject = "abcdef";$pattern = '/^def/';preg_match($pattern, $subject, $matches);print_r($matches);?>
^表示开头,但字符串开头是abc而不是def,所以不能匹配
因为正则没有匹配,如果你想找最后的应该是 /def$/ ,这样就应该有输出了
<?php$subject = "abcdef";$pattern = '/^def/';preg_match($pattern, $subject, $matches);print_r($matches);?>