Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick Switch question... 1

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
US
I have a url that opens up...


here is my coding...

<?switch ('$res'){
case '800':
$nwid = '100';
break;
case '1024':
$nwid = '200';
break;
default:
$nwid = '300';
}
?>

<?
echo $nwid;
?>

What do I have to do to get the value to show up correctly... it should be 200 but shows up 300 so I think I am referencing res wrong...
 
For additional future reference, anything inside single quotes (') gets evaluated as a literal. So instead of you passing 1024 to the switch statement, you were passing the literal $res. If you used double quotes, or no quotes at all (and you had register_globals turned on), it would have worked the same. But jpadie's way is the best. You should always code as if register_globals is off and access things explicity by their global array name.

Just a tidbit of info.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top