Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    switch is missreading zeros

    I am trying to use a switch function to display a different text message according to the numeric value of a variable. It keeps missreading zeros and treating them as ones. Is there something obvious I am missing?

    here is my code

    switch ($pagetype)
    {
    case $pagetype == 0:
    echo "Standard";
    break;
    case $pagetype == 1:
    echo "Custom (using include)";
    break;
    case $pagetype == 2:
    echo "External Link (same window)";
    break;
    case $pagetype == 3:
    echo "External Link (new window)";
    break;
    default:
    echo "Standard";
    }

    if I pass it the variable $pagetype when it equals 0 It responds with "custom (using include)"

    sametch

  • #2
    New Coder
    Join Date
    Jan 2003
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No need to reply, got it it should read "case 0:" NOT "case $pagetype == 0: "



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •