Detect Browser Language in PHP

    $lang = getenv("HTTP_ACCEPT_LANGUAGE");
    $set_lang = explode(',', $lang);
    if (isset($_POST['lang'])) 
            $taal = $_POST['lang'];
            setcookie("lang", $taal);
            header('Location: /p/');
            setcookie("lang", $set_lang[0]);
            echo $set_lang[0];
            echo '<br>';
            echo $set_lang[1];
            header('Location: /p/');

Nivo slider options

effect: 'random', // Specify sets like: 'fold,fade,sliceDown'
slices: 15, // For slice animations
boxCols: 8, // For box animations
boxRows: 4, // For box animations
animSpeed: 500, // Slide transition speed
pauseTime: 3000, // How long each slide will show
startSlide: 0, // Set starting Slide (0 index)
directionNav: true, // Next & Prev navigation
controlNav: true, // 1,2,3... navigation
controlNavThumbs: false, // Use thumbnails for Control Nav
pauseOnHover: true, // Stop animation while hovering
manualAdvance: false, // Force manual transitions
prevText: 'Prev', // Prev directionNav text
nextText: 'Next', // Next directionNav text
randomStart: false, // Start on a random slide
beforeChange: function(){}, // Triggers before a slide transition
afterChange: function(){}, // Triggers after a slide transition
slideshowEnd: function(){}, // Triggers after all slides have been shown
lastSlide: function(){}, // Triggers when last slide is shown
afterLoad: function(){} // Triggers when slider has loaded

PDO connection with MySQL

# gestione delle eccezioni in fase di connessione con PDO

// collegamento al database
$col = 'mysql:host=localhost;dbname=DATABASE_NAME';

// blocco try per il lancio dell'istruzione
try {
  // connessione tramite creazione di un oggetto PDO
  $db = new PDO($col , 'username', 'password');
// blocco catch per la gestione delle eccezioni
catch(PDOException $e) {
  // notifica in caso di errorre
  echo 'Attenzione: '.$e->getMessage();

/* disabilitazione dell'auto-commit

// esecuzione delle query
$sql = $db->exec("UPDATE filnet_page SET img_code = 'AU002.jpgTEST' WHERE id = 67");

// applicazione delle modifiche
$db->commit(); */

# utilizzo del metodo query()

// definizione della query 
$sql = 'SELECT field1, field2 FROM table_name ORDER BY id';  

// visualizzazione dei risultati
foreach($db->query($sql) as $row){  ?>

PHP directory listing in reverse order, function rsort


(PHP 4, PHP 5)

rsort — Sort an array in reverse order

Case history

PHP directory listing in reverse order


bool rsort ( array &$array [, int $sort_flags = SORT_REGULAR ] )

This function sorts an array in reverse order (highest to lowest).


The input array.

You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort().

Return Values

Returns TRUE on success or FALSE on failure.


Example #1 rsort() example

$fruits = array("lemon", "orange", "banana", "apple");
foreach ($fruits as $key => $val) {
    echo "$key = $val\n";


0 = orange
1 = lemon
2 = banana
3 = apple


PHP function calculate the distance between two coordinates (latitude, longitude)

function distance($lat1, $lng1, $lat2, $lng2, $miles = true)
$pi80 = M_PI / 180;
$lat1 *= $pi80;
$lng1 *= $pi80;
$lat2 *= $pi80;
$lng2 *= $pi80;

$r = 6372.797; // mean radius of Earth in km
$dlat = $lat2 - $lat1;
$dlng = $lng2 - $lng1;
$a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2);
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
$km = $r * $c;

return ($miles ? ($km * 0.621371192) : $km);

Dreamweaver Help / Server behaviors, databases, and bindings in Dreamweaver CC

This document addresses queries around server behaviors, the Bindings panel, and databases in Dreamweaver CC released on June 18 2013.

In Dreamweaver CC, server behaviors are available as an extension, Deprecated_ServerBehaviorsPanel_Support.zxp. After you install the extension, the server behaviors feature is enabled and extensions dependent on it work as they did previously.

In the CC release, based on your OS, you can find the extension at the locations below.

  •  Vista/Windows 7: C:/Program Files (x86)/Adobe/Adobe Dreamweaver CC/Configuration/DisabledFeatures
  •  Mac OS X: /Applications/Adobe Dreamweaver CC/Configuration/DisabledFeatures


MXP type extensions are not supported in Extension Manager CC. The MXP format has been replaced with the ZXP extension format.

An MXP extension can be converted to a ZXP extension using the “Convert MXP Extension To ZXP” tool. This tool can be found in the Tools menu in Extension Manager for CS6.