dongwen2896 2017-02-02 10:02
浏览 18

获取值未正确更新(更改语言)

I am trying to add different languages to my website by using sessions. But for some reason the language always stays on NL. My setup is like this:

header.php

(Only relevant code: )

include 'includes/connection.php';
include 'includes/lang.php';

<div id="lang-selector" class="dropdown">
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    <a href="<? echo $actual_link; ?>?lang=en" class="btn-selector">EN</a>
    <ul>
    <li class="active"><a href="<? echo $actual_link; ?>?lang=en">EN</a></li>
    <li><a href="<? echo $actual_link; ?>?lang=fr">FR</a></li>
  <li><a href="<? echo $actual_link; ?>?lang=nl">NL</a></li>
    </ul>
</div>

Connection.php

(again only relevant code: )

session_start();

if ($_GET['lang'] != '') {
    $_SESSION['lang'] = $_GET['lang'];
} else if ($_SESSION['lang'] == '') {
    $_SESSION['lang'] = 'fr';
}

And my language file:

if($_SESSION['lang'] == 'nl') {

  //footer
  $copyright = 'Alle rechten voorbehouden';
}else if($_SESSION['lang'] == 'en'){

  //footer
  $copyright = 'All rights reserved';
}else if($_SESSION['lang'] == 'fr'){

  //footer
  $copyright = 'Tous droits réservés';
}

Why does my language always stay at nl? Even though I set the standard to fr in my connection.php. I also echoed the session value, and it says nl even when I add ?lang=fr manually to the url.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测