Intrebari si Tutoriale: PHP
Alternativa get_browser() browscap.ini
Adaugat de Flaviu Ghitulescu on 01 April 2015 11:48 AM

In cazul in care doriti sa folositi functia get_browser() alternativa este clasa phpbrowscap:

https://github.com/GaretJax/phpbrowscap

Avantaje:

  • de pana la 20 de ori mai rapid ca functia php get_browser()
  • de sine statator, nu este nevoie de modificari in php.ini
  • auto detectie
  • returneaza valorile in array
  • compatibil cu php 5.3

Exemplu de utilizare:

<?php

// Loads the class
require 'path/to/Browscap.php';

// The Browscap class is in the phpbrowscap namespace, so import it
use phpbrowscap\Browscap;

// Create a new Browscap object (loads or creates the cache)
$bc = new Browscap('path/to/the/cache/dir');

// Get information about the current browser's user agent
$current_browser = $bc->getBrowser();

// Output the result
echo '<pre>'; // some formatting issues ;)
print_r($current_browser);
echo '</pre>';
(2 voturi)
Acest articol a fost de ajutor
Acest articol nu a fost de ajutor