0

I have a page that displays an include depending on language selected. It works perfectly in Classic ASP, but I have converted to PHP and it is ignoring the IF condition completely. For example:

if ($Lang = "AR") {
    include 'inc_default_ar.php';
} elseif ($Lang = "CN") {
    include 'inc_default_cn.php';
} elseif ($Lang = "CS") {
    include 'inc_default_cs.php';
} else {
    include 'inc_default_en.php';
}

Even though $Lang = "EN" it somehow displays the AR include, even though it is not a match.

Taher A. Ghaleb
  • 5,120
  • 5
  • 31
  • 44
WilliamK
  • 821
  • 1
  • 13
  • 32

2 Answers2

4

You should use == to check for equality.

if ($Lang == "AR") {
    include 'inc_default_ar.php';
} elseif ($Lang == "CN") {
    include 'inc_default_cn.php';
} elseif ($Lang == "CS") {
    include 'inc_default_cs.php';
} else {
    include 'inc_default_en.php';
}
pew007
  • 453
  • 2
  • 7
  • 17
3

I agree with @pew007's answer. But if you change up your code a little bit and always have the $Lang variable set you could do something like the following.

include "inc_default_".strtolower($Lang).".php"
Beans
  • 379
  • 4
  • 13