它说第10行我有错误,不知道为什么
继承我的代码:
<?php
$os1= (isset($_GET['number']) && ($_GET['number'] == 'one' || $_GET['number'] == 'two' || $_GET['number'] == 'three'));
$os2= (isset($_GET['number']) && ($_GET['number'] == 'four' || $_GET['number'] == 'five' || $_GET['number'] == 'six'));
if ($os1)
{
$title = "Windows 8";
$title2 = "User"
}
else ($os2)
{
$title = "OSX Yosimite";
$title2 = "User"
}
echo $title1;
echo $title2;
?>
答案 0 :(得分:1)
您在两个地方缺少;
:
if ($os1)
{
$title = "Windows 8";
$title2 = "User"; // add ; here
}
else ($os2)
{
$title = "OSX Yosimite";
$title2 = "User"; // add ; here
}
更改
else ($os2)
到
else if ($os2)
以上逻辑适合作为解决方案,就好像我们只使用else
而不是else if
一样,没有使用变量$os2
。
再次
更改
echo $title1;
到
echo $title;
答案 1 :(得分:0)
失踪;排在第10位; 15
<?php
$os1= (isset($_GET['number']) && ($_GET['number'] == 'one' || $_GET['number'] == 'two' || $_GET['number'] == 'three'));
$os2= (isset($_GET['number']) && ($_GET['number'] == 'four' || $_GET['number'] == 'five' || $_GET['number'] == 'six'));
if ($os1)
{
$title = "Windows 8";
$title2 = "User";
}
else ($os2)
{
$title = "OSX Yosimite";
$title2 = "User";
}
echo $title1;
echo
$title2;
?>
答案 2 :(得分:0)
变量&#34; $ title1&#34;未定义任何位置(或)在打印前不指定任何值。
echo $ title1;
答案 3 :(得分:0)
您在第9行和第15行的末尾错过了分号(;)。请检查。
每一行都应以PHP中的分号结尾,否则它会给我们带来错误:-D
答案 4 :(得分:0)
<?php
$arr1=array("one","two","three");
$arr2= array("four","five","six");
if(isset($_GET['number']) && in_array($_GET['number'],$arr1))
{
$title = "Windows 8";
$title2 = "User";
}
elseif (if(isset($_GET['number']) && in_array($_GET['number'],$arr2)))
{
$title = "OSX Yosimite";
$title2 = "User";
}
echo $title;
echo $title2;
?>
希望它对你有用。