PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Eduardo "Trial Force" Bonfandini   PHP User Agent Detection   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Test/example file
Class: PHP User Agent Detection
Determine the type of browser from the user agent
Author: By
Last change:
Date: 10 years ago
Size: 1,153 bytes
 

Contents

Class file image Download
<?php

require 'useragent.php';
//current
$userAgent[] = new \UserAgent( );
//Chrome 32
$userAgent[] = new \UserAgent( 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.102 Safari/537.36' );
//firefox 26
$userAgent[] = new \UserAgent( 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0' );
//ie9
$userAgent[] = new \UserAgent( 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)' );
//ie9 with ie8 mode
$userAgent[] = new \UserAgent( 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)' );
//ie9 with ie7 mode
$userAgent[] = new \UserAgent( 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E' );
//safari windows
$userAgent[] = new \UserAgent( 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2' );

var_dump( $userAgent );