PHP UI 語系切換

PHP UI 語系切換

PHP UI 語系切換

資料來源:http://echochio.pixnet.net/blog/post/45413880
 
session_start();
if(!isset($_SESSION[‘language’]))
{
    switch (substr($_SERVER[‘HTTP_ACCEPT_LANGUAGE’], 0, 2)) {
        case “zh”:
            $_SESSION[‘language’] = “Simp”;
            if (substr($_SERVER[‘HTTP_ACCEPT_LANGUAGE’], 0, 5) == “zh-tw”)
                {$_SESSION[‘language’] = “Chinese”; }
            if (substr($_SERVER[‘HTTP_ACCEPT_LANGUAGE’], 0, 5) == “zh-TW”)
                {$_SESSION[‘language’] = “Chinese”; }
            break;
        case “ja”:
            $_SESSION[‘language’] = “Japanese”;
            break;
        default :
            $_SESSION[‘language’] = “English”;
    }
}
switch ($_SESSION[‘language’])
{
    case “Japanese”:
        //echo “Japanese”;
        include_once(‘Jp.php’);
        break;
    case “English”:
        //echo “English”;
        include_once(‘En.php’);
        break;
    case “Simp”:
        //echo “Simp”;
        include_once(‘Sc.php’);
         break;
    default:
         //echo “Chinese”;
         include_once(Ch.php’);
}

 

 

 

 

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *