From fd67de73e426de842bbc92f71f1827a4ec3328ea Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Wed, 15 Jun 2022 11:15:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=96=B9=E6=B3=95=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=E5=85=BC=E5=AE=B9=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/app/common.php b/app/common.php index d74c47d1c..879c51ff3 100755 --- a/app/common.php +++ b/app/common.php @@ -2849,4 +2849,44 @@ function ParamsChecked($data, $params) } return true; } + +// php系统方法不存在则定义 +if(!function_exists('str_starts_with')) +{ + /** + * 检查字符串是否以给定的子字符串开头 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2022-06-15 + * @desc description + * @param [string] $haystack [待检查的字符串] + * @param [string] $needle [需检查的字符串] + * @return [boolean] [true|false] + */ + function str_starts_with($haystack, $needle) + { + $len = mb_strlen($needle, 'utf-8'); + return mb_substr($haystack, 0, $len, 'utf-8') === $needle; + } +} +if(!function_exists('str_ends_with')) +{ + /** + * 检查字符串是否以给定的子字符串结尾 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2022-06-15 + * @desc description + * @param [string] $haystack [待检查的字符串] + * @param [string] $needle [需检查的字符串] + * @return [boolean] [true|false] + */ + function str_ends_with($haystack, $needle) + { + $len = mb_strlen($needle, 'utf-8'); + return mb_substr($haystack, -1, $len, 'utf-8') === $needle; + } +} ?> \ No newline at end of file