a missing variable in a switch statement ?!!

Posted by mechhfly on Stack Overflow See other posts from Stack Overflow or by mechhfly
Published on 2010-04-30T00:23:58Z Indexed on 2010/04/30 0:27 UTC
Read the original article Hit count: 492

Filed under:

hi folks, i have a strange issue. a variable seems to be missing during a pass through a case statement

i have a function like so

function checklink($var0, $var1, $var2)
{
  switch($var0)
  {
    case "case1":
      print $var2;
      //code uses $var2 successfully
    case "case2":
      print $var2;
      //variable has disappeared!
  }

}

essentially what i am doing is constructing a string from the last variable based on the first. if i run the code in which the first case is true, i get the expected results, but when i run the second case, my variable seems to have vanished. these first two case statements are syntactically the same and the variable is gathered from the $_GET array (hard coded into hyperlink). any light on this issue?
if more explanation is needed let me know, its late and my brain is getting mushy.

thanks my friends.

© Stack Overflow or respective owner

Related posts about php5