3

We're getting an integer with : JFactory::getApplication()->client->browser;

Is there a way to get the browser name?

4

Browser's names are set as integer CONSTANTS inside the JApplicationWebClient Class ('/libraries/joomla/application/web/client.php')

More resources:

Getting the browser name:

You could get the Constants of the Class in an array using PHP's Reflection API, like so:

$clientReflector = new ReflectionClass('JApplicationWebClient');
$browsers_array = $clientReflector->getConstants();
print_r($browsers_array);

This will result to the following:

Array
(
    [WINDOWS] => 1
    [WINDOWS_PHONE] => 2
    [WINDOWS_CE] => 3
    [IPHONE] => 4
    [IPAD] => 5
    [IPOD] => 6
    [MAC] => 7
    [BLACKBERRY] => 8
    [ANDROID] => 9
    [LINUX] => 10
    [TRIDENT] => 11
    [WEBKIT] => 12
    [GECKO] => 13
    [PRESTO] => 14
    [KHTML] => 15
    [AMAYA] => 16
    [IE] => 17
    [FIREFOX] => 18
    [CHROME] => 19
    [SAFARI] => 20
    [OPERA] => 21
    [ANDROIDTABLET] => 22
)

There is also the

JFactory::getApplication()->client->userAgent; 

which would return the full user agent's string, e.g.:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:46.0) Gecko/20100101 Firefox/46.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.