搜索
首页PHP 库Other librariesMobile解析字符串的PHP库
Mobile解析字符串的PHP库
<?php
if( file_exists(dirname(__FILE__).'/nicejson/nicejson.php') ) {
include_once dirname(__FILE__).'/nicejson/nicejson.php';
}
require_once dirname(__FILE__).'/../Mobile_Detect.php';
$detect = new Mobile_Detect;
$json = array(
// The current version of Mobile Detect class that
// is being exported.
'version' => $detect->getScriptVersion(),
// All headers that trigger 'isMobile' to be 'true',
// before reaching the User-Agent match detection.
'headerMatch' => $detect->getMobileHeaders(),
// All possible User-Agent headers.
'uaHttpHeaders' => $detect->getUaHttpHeaders(),
// All the regexes that trigger 'isMobile' or 'isTablet'
// to be true.
'uaMatch' => array(
// If match is found, triggers 'isMobile' to be true.
'phones'   => $detect->getPhoneDevices(),
// Triggers 'isTablet' to be true.
'tablets'  => $detect->getTabletDevices(),
// If match is found, triggers 'isMobile' to be true.
'browsers' => $detect->getBrowsers(),
// If match is found, triggers 'isMobile' to be true.
'os'       => $detect->getOperatingSystems(),
// Various utilities. To be further discussed.
'utilities' => $detect->getUtilities()
)
);

字符串主要用于编程,概念说明、函数解释、用法详述见正文,这里补充一点:字符串在存储上类似字符数组,所以它每一位的单个元素都是可以提取的,如s=“abcdefghij”,则s[1]=“a”,s[10]="j",而字符串的零位正是它的长度,如s[0]=10(※上述功能Ansistring没有。),这可以给我们提供很多方便,如高精度运算时每一位都可以转化为数字存入数组。

免责声明

本站所有资源均由网友贡献或各大下载网站转载。请自行检查软件的完整性!本站所有资源仅供学习参考。请不要将它们用于商业目的。否则,一切后果由您负责!如有侵权,请联系我们删除。联系方式:admin@php.cn

相关文章

如何解析带单引号的 JSON 字符串?如何解析带单引号的 JSON 字符串?

02Dec2024

解析带有单引号的 JSON 字符串尝试使用标准 JSON.parse() 方法解析包含单引号的 JSON 字符串可能会导致...

如何从字符串中解析日期以插入 MySQL 数据库?如何从字符串中解析日期以插入 MySQL 数据库?

03Dec2024

MySQL 插入的解析日期MySQL 提供了格式化和解析日期的函数。虽然 DATE_FORMAT() 用于从...转换

如何轻松解析 JavaScript 中的查询字符串?如何轻松解析 JavaScript 中的查询字符串?

25Nov2024

如何在 JavaScript 中解析查询字符串在 Web 开发中,查询字符串通常用于将数据传递到服务器端应用程序。尽管...

如何解析包含单引号的JSON字符串?如何解析包含单引号的JSON字符串?

15Dec2024

解析带有单引号的 JSON 当尝试解析带有单引号的 JSON 字符串时,例如 str = "{'a':1};",您可能会遇到...

如何准确地解析C#中的DateTime字符串?如何准确地解析C#中的DateTime字符串?

31Jan2025

在使用DateTime字符串时,将字符串正确解析到C#中,至关重要的是要准确解析它们以操纵DateTime值...

如何将字符串解析为C#中的枚举?如何将字符串解析为C#中的枚举?

02Feb2025

在C#中使用HTML形式和枚举时,将字符串解析为枚举中的枚举,可能需要将字符串值转换为其...

See all articles