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

Control Flow: Switch Forum

View Course » View Exercise

215 points
Submitted by
almost 3 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

$Username = "BZoneZ";

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

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

0 votes


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

1208 points
Submitted by
over 2 years ago