php 判断字符串是否以某字符串结尾的方法

// $str:原字符串,$suffix:子字符串(区分大小写)
public static function endWith($str, $suffix)
{   
    $length = strlen($suffix);
    if ($length == 0) {
        return true;
    }   
    return (substr($str, -$length) === $suffix);
} 
原文地址:https://www.cnblogs.com/aze999/p/15626064.html