An open API service indexing awesome lists of open source software.

https://github.com/zencephalon/useragent

Translation of useragent into PHP
https://github.com/zencephalon/useragent

Last synced: over 1 year ago
JSON representation

Translation of useragent into PHP

Awesome Lists containing this project

README

          

#Sail\UserAgent

Install with composer:
``` json
{
"require": {
"sail/useragent": "1.0.*"
},
"repositories": [{
"type": "vcs",
"url": "https://github.com/zencephalon/useragent"
}]
}
```

create an index.php file:
``` php

$test----------------------------
";

$parser = new SailParser( $useragent );
$ua = new UserAgent( $parser );

echo $ua;
echo "
";

echo "
Browser: ";
echo $ua->getBrowser();

echo " v";
echo $ua->getVersion();

echo "
Is mobile: ";
echo $ua->isMobile() ? "YES" : "NO";

echo "
";
if( $ua->getBrowser() == "MSIE" && $ua->getVersion() < 8 ){
echo "browser not supported";
}
else{
echo "browser supported";
}

echo "
is internet explorer 8 ";
if( $ua->getBrowser() == "Internet Explorer" && preg_match( "/^8/", $ua->getVersion() ) ){
echo "YES";
}
else{
echo "NO";
}
}

```