在php中使用语言包,

浏览:2557 发布日期:2016/08/25 分类:功能实现 关键字: php
中英文切换,有什么好的思路大家可以留言
<a id="chinese" <?php if(isset($_COOKIE['version']) && $_COOKIE['version'] == "cn"){ ?> class="active" <?php } ?> href="<?php echo __DOMAIN__;?>/index.php?c=index&a=index&version=cn">中文</a>
<a id="english" <?php if(isset($_COOKIE['version']) && $_COOKIE['version'] == "en"){ ?> class="active" <?php } ?> href="<?php echo __DOMAIN__;?>/index.php?c=index&a=index&version=en">English</a></div>
​在控制器:
​判断用户点击的是哪个语言
if(isset($_GET['version'])){
$version = $_GET['version'];
setcookie("version",$version,time()+(3600*24),"/");
}
。在前段判断cookie值即可:

<?php if(isset($_COOKIE['version']) && $_COOKIE['version'] == "cn"){ ?>
​ <div class="fl"><h3><?php echo $value['g_name'] ?></h3></div>
​ ​<span class="eng fl">    <?php echo $value['g_name_e'] ?></span>
<?php } else {?>
​ <div class="fl"><h3><?php echo $value['g_name_e'] ?></h3></div>
<?php }?>
评论( 相关
后面还有条评论,点击查看>>