サンプル
初期化
<?php
require_once 'Net/UserAgent/Mobile.php';
$mobile = Net_UserAgent_Mobile::factory();
?>
name
<?php
var_dump($mobile->name);
?>
実行結果
string(7) "Mozilla"
version
<?php
var_dump($mobile->version);
?>
実行結果
string(15) "5.0 AppleWebKit"
getUserAgent()
<?php
var_dump($mobile->getUserAgent());
?>
実行結果
string(103) "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)"
getHeader($header)
<?php
echo htmlspecialchars($mobile->getHeader('REFERER'), ENT_QUOTES, mb_internal_encoding());
?>
実行結果
getName()
<?php
var_dump($mobile->getName());
?>
実行結果
string(7) "Mozilla"
getDisplay()
<?php
var_dump($mobile->getDisplay());
?>
実行結果
object(Net_UserAgent_Mobile_Display)#162 (6) {
["_width"]=>
int(0)
["_height"]=>
int(0)
["_depth"]=>
int(0)
["_color"]=>
bool(false)
["_widthBytes"]=>
int(0)
["_heightBytes"]=>
int(0)
}
getVersion()
<?php
var_dump($mobile->getVersion());
?>
実行結果
string(15) "5.0 AppleWebKit"
noMatch()
<?php
$error = $mobile->noMatch();
echo $error->getMessage();
?>
実行結果
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com): 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)#164 (6) {
["_width"]=>
int(0)
["_height"]=>
int(0)
["_depth"]=>
int(0)
["_color"]=>
bool(false)
["_widthBytes"]=>
int(0)
["_heightBytes"]=>
int(0)
}
isDoCoMo()
<?php
var_dump($mobile->isDoCoMo());
?>
実行結果
bool(false)
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(true)
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) "N"
getCarrierLongName()
<?php
var_dump($mobile->getCarrierLongName());
?>
実行結果
string(9) "NonMobile"
isSoftBank()
<?php
var_dump($mobile->isSoftBank());
?>
実行結果
bool(false)
isWillcom()
<?php
var_dump($mobile->isWillcom());
?>
実行結果
bool(false)
getModel()
<?php
var_dump($mobile->getModel());
?>
実行結果
NULL
getRawModel()
<?php
var_dump($mobile->getRawModel());
?>
実行結果
NULL
getUID()
<?php
var_dump($mobile->getUID());
?>
実行結果
NULL