Review Questions: Week 3 (Control Strutures)
<?php $string1 = "cake"; $string2 = "foo"; if($string1==$string2) { print "\$string1=".$string1."<br>"; print "\$string2=".$string2."<br>"; echo "cake is not a lie. <br>"; } ?>
<?php $string1 = "cake"; $string2 = "foo";
if($string1==$string2) { print "\$string1=".$string1."<br>"; print "\$string2=".$string2."<br>"; echo "cake is not a lie. <br>"; } ?>
if($string1!=$string2) { print "\$string1=".$string1."<br>"; print "\$string2=".$string2."<br>"; echo "cake is not a lie. <br>"; } ?>
if($string1=$string2) { print "\$string1=".$string1."<br>"; print "\$string2=".$string2."<br>"; echo "cake is a lie. <br>"; } ?>
if(!$string1==$string2) { print "\$string1=".$string1."<br>"; print "\$string2=".$string2."<br>"; echo "cake is a lie. <br>"; } ?>
<?php $i="bar";
switch ($i) {
case "apple": echo "i is apple  "; break; case "bar": echo "i is bar  "; break; case "cake": echo "i is cake  "; break; default: echo "i is nothing "; break;
} ?>
switch ($i)
{ case "apple": echo "i is apple  "; break; case "bar": echo "i is bar  "; break case "cake": echo "i is cake  "; break; default: echo "i is nothing  "; break; }
?>
{ case "apple": echo "i is apple<br>"; break; case "bar": echo "i is bar<br>"; case "cake": echo "i is cake<br>"; break; default: echo "i is nothing<br>"; break; }
<?php
$myVariable = 2; do { echo $myVariable; } while ($myVariable > 3);
$myVariable = 2; while ($myVariable > 3) { echo $myVariable; }
<?php $MyArray = array("one", "two", "three");
foreach ($MyArray as $value) { echo "Value: $value,; } ?>
$myVariable = 4; while ($myVariable > 3) { echo $myVariable; }