我有一个网站,在该网站中,根据解析到URL的查询字符串创建了会话。我正在读取会话值,因此想要更改网站的标题。事情可以在下面的代码下正常运行,但不会进入elseif条件。如果我尝试打印会话值,它会给我正确的回显,但条件不能正常工作。它可以与If和else一起使用,但不能进入ElseIf
override func viewDidLoad() {
super.viewDidLoad()
refRepairs = Database.database().reference().child("repairs");
//observing the data changes
refRepairs!.observe(DataEventType.value, with: { (snapshot) in
...
答案 0 :(得分:1)
您的条件不正确,请结合使用:
if(isset($_SESSION["mycid"]) && $_SESSION["mycid"] == "14")
...
elseif(isset($_SESSION["mycid"]) && $_SESSION["mycid"] == "8")
更有效的方法是只检查外部if
中的isset一次,然后检查值:
if(isset($_SESSION["mycid"]))
{
if($_SESSION["mycid"] == "14")
{
...
}
elseif($_SESSION["mycid"] == "8")
{
...
}
else
{
...
}
}
else
{
//action for $_SESSION["mycid"] not set
}
答案 1 :(得分:0)
尝试一下
if (isset($_SESSION["mycid"])) {
switch ($_SESSION["mycid"]) {
case 7:
$storeTitle = "Jet Airways BrandSTORE";
$storeDLogo = "/images/jetAirwaysLogo.jpg";
$storecolor1 = "#000"; //applied in header background
$storecolor2 = "#FF9304"; //applied in mini header background
$storeGDlogo = "/images/globaJLinkerLogo.jpg";
$storeGMlogo = "/images/globaJLinkerLogo.jpg";
break;
case 8:
$storeTitle = "Jet Airways BrandSTORE";
$storeDLogo = "/images/jetAirwaysLogo.jpg";
$storeGDlogo = "/images/globaJLinkerLogo.jpg";
$storeGMlogo = "/images/globaJLinkerLogo.jpg";
break;
case 9:
$storeTitle = "Jet Airways BrandSTORE";
$storeDLogo = "/images/jetAirwaysLogo.jpg";
$storeGDlogo = "/images/globaJLinkerLogo.jpg";
$storeGMlogo = "/images/globaJLinkerLogo.jpg";
break;
case 10:
$storeTitle = "Jet Airways BrandSTORE";
$storeDLogo = "/images/jetAirwaysLogo.jpg";
$storeGDlogo = "/images/globaJLinkerLogo.jpg";
$storeGMlogo = "/images/globaJLinkerLogo.jpg";
break;
case 14:
$storeTitle = "Federation of Indian Exports Organization BrandSTORE";
$storeDLogo = "/images/hid/figo-14.jpg";
$storecolor1 = "#02ADF2"; //applied in header background
$storecolor2 = "#FF9304"; //applied in mini header background
$storeGDlogo = "/images/hid/gl-14.jpg";
$storeGMlogo = "/images/hid/gl-m-14.jpg";
break;
}
} else {
$storeDLogo = "/images/jetAirwaysLogo.jpg";
$storeGDlogo = "/images/globaJLinkerLogo.jpg";
$storeGMlogo = "/images/globaJLinkerLogo.jpg";
}
在这里,请不要忘记传递default values
,由于variables
未能设置condition