// $str:原字符串,$suffix:子字符串(区分大小写) public static function endWith($str, $suffix) { $length = strlen($suffix); if ($length == 0) { return true; } return (substr($str, -$length) === $suffix); }