This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Control Flow: Switch Forum

View Course » View Exercise

215 points
Cbf212caeefde28dc1bec8324cd007c8?s=140&d=retro
Submitted by
KillZoneZ
almost 2 years ago

Control Flow: Switch output error.

So, basically, i want the code to see if the variable Username is "KillZoneZ" or "Admin2", if it is, it would show "Welcome Admin KillZoneZ/Admin2 (For each case), and if it wasn't any of the "KillZoneZ" or "Admin2" it would show "Welcome (Variable $Username)", however it always seem to display Welcome Admin KillZoneZ despite the variable being defined as Admin2 or any other name.

Here is my code

<?php
$Username = "BZoneZ";

    if($Username = "KillZoneZ") {
    echo "Welcome Admin" . " " . $Username;
    }

    elseif($Username = "Admin2") {
    echo "Welcome Admin" . " " . $Username;
}
    else {
    echo "Welcome" . $Username;
    }
    ?>

0 votes

permalink

you're using assignment "=" not comparison "==" in your if statements

1208 points
415e210cbc32dd4ce7747cbccf1b836a?s=140&d=retro
Submitted by
paperalligator
almost 2 years ago