unexpected switch behavior

From: Date: Mon, 07 Oct 2002 23:11:16 +0000
Subject: unexpected switch behavior
Groups: php.general 
Request: Send a blank email to php-general+get-119154@lists.php.net to get a copy of this message
Hello, Getting unexpect behavior for the following switch statement # snippet in example.php switch ($_GET['var']){ case 1: echo 'foo'; break; default: echo 'bar'; } When I enter the following url: http://sub.domain.tld/example.php Page displays: Notice: Undefined index: var in \htdocs\example.php on line 19 bar The unexpected behavior is the displaying of the word bar. What I expected was just the error message. If the switch variable is illegal (or undef), shouldn't it skip the entire switch statement as opposed to executing it using the default case. Thanks for any clarification on this, -Peter ################################## Peter Thoenen - Systems Programmer Commercial Communications Camp Bondsteel, Kosovo ################################## "Stumbled Upon"...heh (Score:5, Funny) /. by $carab on 23:00 23 August 2002 (#4131637) "ForensicTec officials said they stumbled upon the military networks about two months ago, while checking on network security for a private-sector client." Someone new to a Dvorak probably tried to type in "lynx http://www.google.com" but instead got "nmap -v -p 1-1024 -sS -P0 army.mil -T paranoid".

« previous php.general (#119154) next »