「php学習」PHPで表示言語を自動判別する方法
phpコード:
<?php
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE’], 0, 4);
if (preg_match(“/zh-c/i", $lang))
echo “簡体中国語";
else if (preg_match(“/zh/i", $lang))
echo “繁体中国語";
else if (preg_match(“/en/i", $lang))
echo “English";
else if (preg_match(“/fr/i", $lang))
echo “French";
else if (preg_match(“/de/i", $lang))
echo “German";
else if (preg_match(“/jp/i", $lang))
echo “Japanese";
else if (preg_match(“/ko/i", $lang))
echo “Korean";
else if (preg_match(“/es/i", $lang))
echo “Spanish";
else if (preg_match(“/sv/i", $lang))
echo “Swedish";
else echo $_SERVER[“HTTP_ACCEPT_LANGUAGE"];