0

What the heck is wrong with this:

if  ($bb[$id][0] == "bizz")  {
    $BoxType = "bus_box";
} else {
    $Boxtype = "home_box";
}
<div class="<? echo $BoxType; ?>">

$bb[$id][0] can either be 'bizz' or 'home' but no matter what it stops after the first step.

3
  • 1
    Could you edit that so the code reads correctly? And could you also explain what you have done to test it. Commented Jun 9, 2009 at 20:05
  • Thanks - couldn't see the $wood for the $trees! Commented Jun 9, 2009 at 20:07
  • This seems to me like a coffee buffer underrun error. Commented Jun 9, 2009 at 20:15

3 Answers 3

10

PHP variables are case sensitive. The 'T' in $BoxType is lower case in the else block.

Sign up to request clarification or add additional context in comments.

Comments

5

Not entirely related to your question (which has already been answered), but you may be interested in the ternary operator :)

<div class="<?= $bb[$id][0] == "bizz" ? "bus_box" : "home_box" ?>">

Comments

1

Explain what you mean by "it stops after the first step". Tom is correct, $BoxType and $Boxtype are the not same variables, but it sounds like $BoxType is always getting "bus_box". If it were really "stopping after the first step", $BoxType would just be whatever it was initialized to in the event that $bb[$id][0] was "bizz" and $Boxtype would be "home_box".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.