サンプル
初期化
<?php
require_once 'Net/UserAgent/Mobile.php';
$mobile = Net_UserAgent_Mobile::factory('DoCoMo/2.0 SH706ie(c100;TB;W20H13)');
?>
name
<?php
var_dump($mobile->name);
?>
実行結果
string(6) "DoCoMo"
version
<?php
var_dump($mobile->version);
?>
実行結果
string(3) "2.0"
getUserAgent()
<?php
var_dump($mobile->getUserAgent());
?>
実行結果
string(34) "DoCoMo/2.0 SH706ie(c100;TB;W20H13)"
getHeader($header)
<?php
echo htmlspecialchars($mobile->getHeader('REFERER'), ENT_QUOTES, mb_internal_encoding());
?>
実行結果
getName()
<?php
var_dump($mobile->getName());
?>
実行結果
string(6) "DoCoMo"
getDisplay()
<?php
var_dump($mobile->getDisplay());
?>
実行結果
object(Net_UserAgent_Mobile_Display)#163 (6) {
["_width"]=>
int(240)
["_height"]=>
int(320)
["_depth"]=>
int(262144)
["_color"]=>
bool(true)
["_widthBytes"]=>
int(20)
["_heightBytes"]=>
int(13)
}
getVersion()
<?php
var_dump($mobile->getVersion());
?>
実行結果
string(3) "2.0"
noMatch()
<?php
$error = $mobile->noMatch();
echo $error->getMessage();
?>
実行結果
DoCoMo/2.0 SH706ie(c100;TB;W20H13): might be new variants. Please contact the author of Net_UserAgent_Mobile!
parse($userAgent)
<?php
var_dump($mobile->parse($userAgent));
?>
実行結果
NULL
makeDisplay()
<?php
var_dump($mobile->makeDisplay());
?>
実行結果
object(Net_UserAgent_Mobile_Display)#165 (6) {
["_width"]=>
int(240)
["_height"]=>
int(320)
["_depth"]=>
int(262144)
["_color"]=>
bool(true)
["_widthBytes"]=>
int(20)
["_heightBytes"]=>
int(13)
}
isDoCoMo()
<?php
var_dump($mobile->isDoCoMo());
?>
実行結果
bool(true)
isJPhone()
<?php
var_dump($mobile->isJPhone());
?>
実行結果
bool(false)
isVodafone()
<?php
var_dump($mobile->isVodafone());
?>
実行結果
bool(false)
isEZweb()
<?php
var_dump($mobile->isEZweb());
?>
実行結果
bool(false)
isAirHPhone()
<?php
var_dump($mobile->isAirHPhone());
?>
実行結果
bool(false)
isNonMobile()
<?php
var_dump($mobile->isNonMobile());
?>
実行結果
bool(false)
isTUKa()
<?php
var_dump($mobile->isTUKa());
?>
実行結果
bool(false)
isWAP1()
<?php
var_dump($mobile->isWAP1());
?>
実行結果
bool(false)
isWAP2()
<?php
var_dump($mobile->isWAP2());
?>
実行結果
bool(false)
getCarrierShortName()
<?php
var_dump($mobile->getCarrierShortName());
?>
実行結果
string(1) "I"
getCarrierLongName()
<?php
var_dump($mobile->getCarrierLongName());
?>
実行結果
string(6) "DoCoMo"
isSoftBank()
<?php
var_dump($mobile->isSoftBank());
?>
実行結果
bool(false)
isWillcom()
<?php
var_dump($mobile->isWillcom());
?>
実行結果
bool(false)
getModel()
<?php
var_dump($mobile->getModel());
?>
実行結果
string(7) "SH706ie"
getRawModel()
<?php
var_dump($mobile->getRawModel());
?>
実行結果
string(7) "SH706ie"
getUID()
<?php
var_dump($mobile->getUID());
?>
実行結果
NULL