本文整理汇总了PHP中Mobile_Detect::getRules方法的典型用法代码示例。如果您正苦于以下问题:PHP Mobile_Detect::getRules方法的具体用法?PHP Mobile_Detect::getRules怎么用?PHP Mobile_Detect::getRules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mobile_Detect
的用法示例。
在下文中一共展示了Mobile_Detect::getRules方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRulesExtended
/**
* @covers Mobile_Detect::getMobileDetectionRulesExtended
*/
public function testRulesExtended()
{
$md = new Mobile_Detect();
$count = array_sum(array(count(Mobile_Detect::getPhoneDevices()), count(Mobile_Detect::getTabletDevices()), count(Mobile_Detect::getOperatingSystems()), count(Mobile_Detect::getBrowsers()), count(Mobile_Detect::getUtilities())));
$md->setDetectionType(Mobile_Detect::DETECTION_TYPE_EXTENDED);
$rules = $md->getRules();
$this->assertEquals($count, count($rules));
}
示例2:
?>
class="true"<?php
}
?>
><?php
var_dump($check);
?>
</td>
</tr>
</tbody>
<tbody>
<tr>
<th colspan="2">Custom detection methods</th>
</tr>
<?php
foreach ($detect->getRules() as $name => $regex) {
$check = $detect->{'is' . $name}();
?>
<tr>
<td>is<?php
echo $name;
?>
()</td>
<td <?php
if ($check) {
?>
class="true"<?php
}
?>
><?php
var_dump($check);
示例3: empty
} else {
// non json payload
$response["body"] = empty($HTTP_body) ? null : $HTTP_body;
}
// geoip integration
if ($geoip) {
$ip_source = array("IP-source" => $override_clientip && !empty($headers[$clientip_header]) ? $clientip_header : "REMOTE_ADDR");
$response["geoip_info"] = array_merge($ip_source, get_geoip_info($clientip));
}
// Device detection integration
if ($devicedetect) {
require_once 'vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php';
$detect = new Mobile_Detect();
$response["device"]["is_mobile"] = $detect->isMobile() ? true : false;
$response["device"]["is_tablet"] = $detect->isTablet() ? true : false;
$rules = $detect->getRules();
foreach ($rules as $rule => $value) {
if ($detect->is($rule)) {
$response["device"][$rule] = true;
}
}
}
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
echo PHP_EOL;
} else {
header('Content-Type: text/plain');
echo $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . ' ' . $_SERVER['SERVER_PROTOCOL'] . PHP_EOL;
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
echo "{$header}: {$value}";
echo PHP_EOL;