本文整理汇总了PHP中Mobile_Detect::getScriptVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Mobile_Detect::getScriptVersion方法的具体用法?PHP Mobile_Detect::getScriptVersion怎么用?PHP Mobile_Detect::getScriptVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mobile_Detect
的用法示例。
在下文中一共展示了Mobile_Detect::getScriptVersion方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: version
function version()
{
// instantiate Mobile_Detect Object
$detect = new \Mobile_Detect();
// get version of the Mobile Detector library
$scriptVersion = $detect->getScriptVersion();
// return string value of version
return $scriptVersion;
}
示例2: array
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* -----------------------------------------------------------------------
* The demo is running all the Mobile_Detect's internal methods.
* Here you can spot detections errors instantly.
* -----------------------------------------------------------------------
*
* @author Serban Ghita <serbanghita@gmail.com>
* @license MIT License https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
*
*/
require_once './Mobile_Detect.php';
$detect = new Mobile_Detect();
$deviceType = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer';
$scriptVersion = $detect->getScriptVersion();
if ($deviceType == 'computer') {
$arr = array('os' => "pc");
echo json_encode($arr);
} elseif ($detect->isAndroidOS()) {
$arr = array('os' => "Android");
echo json_encode($arr);
} elseif ($detect->isiOS()) {
$arr = array('os' => "ios");
echo json_encode($arr);
}
示例3: testScriptVersion
/**
* @covers Mobile_Detect::getScriptVersion
*/
public function testScriptVersion()
{
$v = Mobile_Detect::getScriptVersion();
$formatCheck = (bool) preg_match('/^[0-9]+\\.[0-9]+\\.[0-9](-[a-zA-Z0-9])?$/', $v);
$this->assertTrue($formatCheck, "Fails the semantic version test. The version " . var_export($v, true) . ' does not match X.Y.Z pattern');
}
示例4: dirname
* Use the resulting JSON export file in other languages
* other than PHP. Always check for 'version' key because
* new major versions can modify the structure of the JSON file.
*
* The result of running this script is the export.json file.
*
* @license Code and contributions have 'MIT License'
* More details: https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
*
*/
// Included nicejson function to beautify the result JSON file.
// This library is not mandatory.
if (file_exists(dirname(__FILE__) . '/nicejson/nicejson.php')) {
include_once dirname(__FILE__) . '/nicejson/nicejson.php';
}
// Include Mobile Detect.
require_once dirname(__FILE__) . '/../Mobile_Detect.php';
$detect = new Mobile_Detect();
$json = array('version' => $detect->getScriptVersion(), 'headerMatch' => $detect->getMobileHeaders(), 'uaHttpHeaders' => $detect->getUaHttpHeaders(), 'uaMatch' => array('phones' => $detect->getPhoneDevices(), 'tablets' => $detect->getTabletDevices(), 'browsers' => $detect->getBrowsers(), 'os' => $detect->getOperatingSystems(), 'utilities' => $detect->getUtilities()));
$jsonString = function_exists('json_format') ? json_format($json) : json_encode($json);
// Write the JSON file to disk.
// You can import this file in your app.
$fileName = dirname(__FILE__) . '/../Mobile_Detect.json';
$handle = fopen($fileName, 'w');
$fwrite = fwrite($handle, $jsonString);
fclose($handle);
if ($fwrite) {
echo 'Done. Check ' . realpath($fileName) . ' file.';
} else {
echo 'Failed to write ' . realpath($fileName) . ' to disk.';
}
示例5: header
<?php
require_once $strDir . "/lib/Mobile-Detect-2.6.9/Mobile_Detect.php";
$objDetect = new Mobile_Detect();
$strDeviceType = $objDetect->isMobile() ? $objDetect->isTablet() ? 'tablet' : 'phone' : 'computer';
$strScriptVersion = $objDetect->getScriptVersion();
if ($strDeviceType == "tablet" || $strDeviceType == "phone") {
header("Location: " . $strDir . "/mobile/index.php");
exit;
// força parar todo código que venha posteriormente
}
示例6: testScriptVersion
/**
* @covers Mobile_Detect::getScriptVersion
*/
public function testScriptVersion()
{
$v = Mobile_Detect::getScriptVersion();
if (!preg_match('/^[0-9]+\\.[0-9]+\\.[0-9](-[a-zA-Z0-9])?$/', $v)) {
$this->fail("Fails the semantic version test. The version " . var_export($v, true) . ' does not match X.Y.Z pattern');
}
}
示例7: initBeforeCache
/**
* Executed only once. Sets information required for each new UserAgentInfo object.
*/
protected static function initBeforeCache()
{
if (null !== self::$data_version) {
return;
}
$base_dir = UserAgentInfoConfig::$base_dir;
require_once $base_dir . 'UserAgentInfo.class.php';
require_once $base_dir . UserAgentInfoConfig::DIR_IMPORTS . DIRECTORY_SEPARATOR . 'BrowscapWrapper.class.php';
require_once $base_dir . UserAgentInfoConfig::DIR_CACHE . DIRECTORY_SEPARATOR . 'UaiCacheInterface.php';
require_once $base_dir . UserAgentInfoConfig::DIR_CACHE . DIRECTORY_SEPARATOR . UserAgentInfoConfig::CACHE_CLASS_NAME . '.class.php';
if (!in_array('UaiCacheInterface', class_implements(UserAgentInfoConfig::CACHE_CLASS_NAME, false))) {
throw new Exception('Class ' . UserAgentInfoConfig::CACHE_CLASS_NAME . ' doesn\'t implement UaiCacheInterface.');
}
// can be empty
self::$my_user_agent = (string) @$_SERVER['HTTP_USER_AGENT'];
self::$mobile_detect = new Mobile_Detect(self::$fake_md_headers);
self::$uaparser_source_file = $base_dir . self::UAPARSER_JSON_LOCATION;
self::$browscap_source_file = $base_dir . self::BROWSCAP_CACHE_LOCATION;
// this value should change if anything is changed in the source data; the value is human readable (I don't see a need for md5)
self::$data_version = implode(self::SEPARATOR_GENERIC, array(self::CLASS_PARSER_VERSION, filesize(self::$browscap_source_file), BrowscapWrapper::getBrowscapReplacementVersion(), self::$mobile_detect->getScriptVersion(), filesize(self::$uaparser_source_file)));
}