Control Flow :Switch-"Glance at the Past!"


#1

Hello friends ,This is my little code,It doesn't work properly.Can any body point my mistake or give suggestion.


 <?php
    
    $skyColor = "Dark";
    if ($skyColor ="Blue"){
        echo "Enjoy the Sunshine all day long.";
    }
    elseif ($skyColor = "Dark"){
        echo "Expect Heavy Rains!!";
    }
    else {
        echo "Take Umbrella with you.";
    }
    
    ?>



.


#2

if ($skyColor ="Blue"){
        echo "Enjoy the Sunshine all day long.";
    }
    elseif ($skyColor = "Dark"){
        echo "Expect Heavy Rains!!";
    }

use = for assigment
if you want to check whether two values are equal or not then use == or ===


#3

Thanks,This is my corrected code:

<?php
    
    $skyColor = "Dark";
    if ($skyColor =="Blue"){
        echo "Enjoy the Sunshine all day long.";
    }
    elseif ($skyColor == "Dark"){
        echo "Expect Heavy Rains!!";
    }
    else {
        echo "Take Umbrella with you.";
    }
    
    ?>

#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.