$result = preg_match("#^startText(.*)$#i", $string); if($result == 0) { echo "No match"; } else { echo "Match found."; } PHP.net 正则表达式 preg_match 函数返回 0 表示未找到匹配项,返回 1 表示找到第一个匹配项后停止。如果要计算所有匹配项,请使用 preg_match_all 函数。 如需更多帮助请查看 PHP 官网。