PHP code example of arosemena / localechooser

1. Go to this page and download the library: Download arosemena/localechooser 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/ */

    

arosemena / localechooser example snippets


    $chooser = new Arosemena\LanguageChooser\LanguageChooser(['en', 'es'], 'en', 'language');

    $chooser = new Arosemena\LanguageChooser\LanguageChooser(['en', 'es', 'fr'], 'es', 'language');
    // if the browser says that the user prefers french (fr)
    $chooser->obtain(); // returns 'fr'
    // if the browser says that the user prefers german (de)
    $chooser->obtain(); // returns 'es' because it is the default language and german isn't supported
    // if the browser says that the user prefers spanish (es) and sends a cookie named language with the value 'fr'
    $chooser->obtain(); // returns 'fr' because the cookie overrides the browser preferred language