Determine Browser Language


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php if (preg_match('/zh-tw/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) : ?>
  2. var browserlang = "zh-TW";
  3. <?php else : ?>
  4. var browserlang = "<?php echo substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) ?>";
  5. <?php endif; ?>

URL: http://wsqsite.com/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.