doulingzhuang3079 2012-06-02 22:05
浏览 12

PHP如果块仅使用最后一个块

I have code that looks like this:

if ($first == 1); {
$q1 = "1";
$q2 = "2";
$q3 = "3";
}

if ($first == 2); {
$q1 = "1a";
$q2 = "2a";
$q3 = "3a";
}

if ($first == 3); {
$q1 = "1b";
$q2 = "2b";
$q3 = "3b";
}

The variable $first comes out of an array that was sorted earlier. It's a key value from that array.

In this case, the variable is 2, yet the code -always- takes the last block regardless of anything else. So it would report the answers for the 3 block, not the 2 block.

That is to say, getting a value of 1, 2 or 3 for $first will always return 1b for $q1.

Anyone know why? this is making me go insane.

  • 写回答

3条回答 默认 最新

  • douqi1212 2012-06-02 22:06
    关注

    You should not have ; on the end of your if statments. I.e change if ($first == 1); { to this if ($first == 1) {

    评论

报告相同问题?

悬赏问题

  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch