PHP code example of neilime / zf2-browscap

1. Go to this page and download the library: Download neilime/zf2-browscap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

neilime / zf2-browscap example snippets


    
    return array(
        'modules' => array(
            // ...
            'Neilime\Browscap',
        ),
        // ...
    );
    

	
	/* @var $serviceManager \Zend\ServiceManager\ServiceLocatorInterface */	
	
   	$browscap = $serviceManager->get('BrowscapService'); //Retrieve "\Neilime\Browscap\BrowscapService" object
   	var_dump($browscap->getBrowser()); //Display an object which will contain various data elements representing, for instance, the browser's major and minor version numbers and ID string;
   	

 	$browscap = $this->get_browser(); //Retrieve an object
   	echo $browscap->parent;
 	
   	$browscap = $this->get_browser(null,true); //Retrieve an array
   	echo $browscap['parent'];
   	
   	$browscap = $this->get_browser(
   		\Zend\Http\Header\UserAgent::fromString('User-Agent: Mozilla/5.0 (Linux; Android 4.0.4; Desire HD Build/IMM76D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19')
   	); //Retrieve an object with an arbitrary user agent
   	echo $browscap->parent;   	
    

   	$browscap = $this->get_browser(); //Retrieve an object
   	echo $browscap->parent;
   	
   	$browscap = $this->get_browser(null,true); //Retrieve an array
   	echo $browscap['parent'];
   	   	
   	$browscap = $this->get_browser(
   		\Zend\Http\Header\UserAgent::fromString('User-Agent: Mozilla/5.0 (Linux; Android 4.0.4; Desire HD Build/IMM76D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19')
   	); //Retrieve an object with an arbitrary user agent
   	echo $browscap->parent;
   	
bash
    $ php composer.phar update