Women in Technology

Hear us Roar



Article:
  Control Structures Revisited
Subject:   um...isn't this code wrong....
Date:   2002-08-28 12:51:40
From:   minkqulax
Here is your code from the example with the "break" statement


<?php
$menu = "links";
switch($home) {
case "home":
echo "You clicked home";
break;
case "links":
echo "You clicked links";
break;
case "email":
echo "You clicked e-mail";
break;
default:
echo "I don't know what you clicked";
break;
}
?>


That will always produce "I don't know what you clicked" because you set the switch at $home and there is no $home. If you set the switch to $menu...it will work as expected.