...

View Full Version : switch is missreading zeros



sametch
02-28-2003, 06:07 PM
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 :confused:

sametch
02-28-2003, 07:05 PM
No need to reply, got it it should read "case 0:" NOT "case $pagetype == 0: "

:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum