当前位置:首页 > 未分类

PHP如何判断访问来源是微信小程序、公众号平台、APP

admin2年前 (2024-04-12)未分类12079
    //判断是什么平台
    function platform()
    {
        //ll($_SERVER['HTTP_USER_AGENT']);
        $platform='h5';
        $a_strtolower = strtolower($_SERVER['HTTP_USER_AGENT']);
        if(strpos($a_strtolower, "micromessenger"))//公众号MicroMessenger
        {
            if(strpos($a_strtolower, "miniprogram"))//小程序
            {
                $platform = 'mpapp';
            }
            else
                $platform = 'wxapp';
        }
        elseif(strpos($a_strtolower, "uni-app") || strpos($a_strtolower, "Html5Plus"))//app
        {
            $platform = 'app';
        }
        return $platform;
    }


原文链接:http://www.yinzhongnet.com/1311.html

扫描二维码推送至手机访问。

版权声明:本文由服务端开发技术分享发布,如需转载请注明出处。

本文链接:https://www.htmlcms.cn/?id=7

分享给朋友:

相关文章

数据库--MySQL:Failed to start LSB: start and stop MySQL.

mysql 启动失败Failed to start LSB: start and stop MySQL.Starting MySQL....The server quit without updating PID file (……查看错误日…

_initialize 和 __construct中不能return

1、构造函数是一个没有返回值的特殊函数,所有即使加上return也没意义,他不会执行的。2、不仅php,所有面向对象的语言的构造函数都没有return。因此正确的方法应该为:…

ThinkPHP6,where和whereLike同时用踩坑记录

ThinkPHP6,where和whereLike同时用踩坑记录。。。// 以下示例共用条件  $where_or=[];    $where_or_i=[];  &…

ThinkPHP 使用withJoin时,field无效的解决办法

ThinkPHP 使用withJoin时,field无效的解决办法:一、 filed 改为使用 visible.    1. 需注意,visible里需要传的是数组,且主表的字段不需要加别名(wher…

MySQL 中 where in 长度过长的解决方法

在使用MySQL数据库时,我们经常会使用 where in 语句来查询一组特定的值,例如:SELECT * FROM students WHERE id IN (1,&n…

PHP去除数组中的 0

1. 使用array_filter()函数$array = [1, 0, 2, 0, 3, 0]; $array = array_filter($a…