Re: switch and register_globals.

From: Date: Tue, 14 May 2002 14:58:54 +0000
Subject: Re: switch and register_globals.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-97541@lists.php.net to get a copy of this message
You can use $_REQUEST['foo'] which looks at all Cookie, Post, and Get data. switch($_REQUEST['foo']) You may have to still wrap the whole thing around an isset(). if(isset($_REQUEST['foo'])) { switch($_REQUEST['foo']) ... ---John Holmes... ----- Original Message ----- From: "Gerard Samuel" <gsam@trini0.org> To: "PHP" <php-general@lists.php.net> Sent: Tuesday, May 14, 2002 10:44 AM Subject: [PHP] switch and register_globals. > Just looking for opinions/comments of how others are working with > switch() while register_globals is off.... > > With register_globals off, switch() has a little handicap. > ie > switch($foo) > { > .... > break; > } > > $foo, is now illegal/not set. So far, I've been using this before > switch statements. > > if (isset($_POST['foo'])) > { > $foo = $_POST['foo']; > } > elseif (isset($_GET['foo'])) > { > $foo = $_GET['foo']; > } > else > { > $foo = FALSE; > } > > Works for me. Ill probably turn it into a function so I dont type as > much :) > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#97541) next »