apijson-php icon indicating copy to clipboard operation
apijson-php copied to clipboard

endsWith方法不存在

Open q326066766 opened this issue 5 years ago • 4 comments

endsWith方法不存在

q326066766 avatar May 11 '19 08:05 q326066766

应该是 ThinkPHP 里的,你确定依赖了 ThinkPHP ?

TommyLemon avatar Jun 06 '19 07:06 TommyLemon

可以不依赖 endwith可以自己写一个

------------------ 原始邮件 ------------------ 发件人: "TommyLemon"[email protected]; 发送时间: 2019年6月6日(星期四) 下午3:20 收件人: "qq547057827/apijson-php"[email protected]; 抄送: "Subscribed"[email protected]; 主题: Re: [qq547057827/apijson-php] endsWith方法不存在 (#2)

应该是 ThinkPHP 里的,你确定依赖了 ThinkPHP ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

qq547057827 avatar Jun 09 '19 11:06 qq547057827

startsWith和endsWith方法提供

if(!function_exists('startsWith')){
    function startsWith($haystack, $needle)
    {
        $length = strlen($needle);
        return (substr($haystack, 0, $length) === $needle);
    }
}


if(!function_exists('endsWith')){
    function endsWith($haystack, $needle)
    {
        $length = strlen($needle);

        return $length === 0 ||
            (substr($haystack, -$length) === $needle);
    }
}

ulikestyle avatar Jul 16 '19 06:07 ulikestyle

@ulikestyle 非常感谢,如果把代码 提交 Pull Request,你也会被加入这个项目的 贡献者名单 哦. 具体步骤可以参考 https://www.zhihu.com/question/21682976/answer/79489643

TommyLemon avatar Jul 16 '19 06:07 TommyLemon