网站进行切换语言后,在搜索框中输入信息,弹出的提示框的语言没有变,同事说传值出现问题,但我不知道哪里有问题session_start();
$language = 'en';
if(isset($_G['lang']) && in_array($_G['lang'], array('en','tc', 'sc'))){//如果lang为true 且 属于数组array里,那么
$language = $_G['lang'];
$_SESSION['parsons_language'] = $language;
}
else if(isset($_SESSION['parsons_language']) && !empty($_SESSION['parsons_language'])){
$language = $_SESSION['parsons_language'];
}
else{
$_SESSION['parsons_language'] = $language;
}
//update by Ace 2014/10/14
//設置語言對應數據庫的數據 存入session 在查詢數據庫的時候可以使用
//比如tc對應數據庫Traditional Chinese
switch($_SESSION['parsons_language']){
case 'tc':
$_SESSION['parsons_language_specific']='Traditional Chinese';
break;
case 'sc':
$_SESSION['parsons_language_specific']='Simplified Chinese';
break;
case 'en':
$_SESSION['parsons_language_specific']='English';
break;
}
2 回答
大DS
TA贡献3条经验 获得超0个赞
switch($_SESSION['parsons_language']){
case 'tc':
$_SESSION['parsons_language_specific']='Traditional Chinese';
break;
case 'sc':
$_SESSION['parsons_language_specific']='Simplified Chinese';
break;
case 'en':
$_SESSION['parsons_language_specific']='English';
break;
}
我觉得$_SESSION['parsons_language'] 传值不是这么写的
$_SESSION['parsons_language'] 这个请用$_G['lang'] 替换。
添加回答
举报
0/150
提交
取消