您的当前位置:首页>全部文章>文章详情

php判断字符串是否以http或https开头

发表于:2024-07-12 10:55:22浏览:343次TAG: #PHP #ThinkPHP

引言

php判断字符串是否以http或https开头

方法

if (!function_exists('is_start_http_or_https')) {

    /**
     * 判断是否以http或https开头
     * @param $url
     * @return false|int
     */
    function is_start_http_or_https($url)
    {
        return preg_match("/^(http:\/\/|https:\/\/).*$/",$url);
    }
}