I'm trying to use PHP to detect certain languages. However, no matter what, it only echos "FR" I don't know why.
<?php
$lang = "en";
if ($lang == "fr" OR "nl") {
echo "FR";
} else {
echo "Nope";
}
?>
EDIT: How about this?
<?php
$lang = "FR";
$numarray = array(1, 2); //change the values accordingly.
if ($lang === "fr" OR $lang === "nl") {
echo "FR";
} elseif(array_rand($numarray) == 1) {
echo "Outcome1";
} else {
echo "Outcome2";
}
?>
EDIT: I found the problem. Strings are case sensitive.
$lang = "en";
if ($lang === "fr" OR $lang === "nl") {
echo "FR";
} else {
echo "Nope";
}
You almost had it. OR needs two statements so just think of each side of the or needing brackets if (($land === "fr") OR ($land === "nl"))
see ur using OR incorrectly try this it works
<?php
$lang = "en";
if ($lang == "fr" or $lang== "nl") {
echo "FR";
} else {
echo "Nope";
}
?>
==
comparison operator will give unexpected results specially when using strings..
try using the following script
<?php
$lang = "en";
if ($lang === "fr" OR $lang === "nl") {
echo "FR";
} else {
echo "Nope";
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.