Re: default value of a variable

From: Date: Thu, 22 Aug 2002 16:06:05 +0000
Subject: Re: default value of a variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-113643@lists.php.net to get a copy of this message
try if ( isset($HTTP_POST_VARS['step']) ) { $step = $HTTP_POST_VARS['step']; { else { $step = 1; } the "!" before isset basically makes it "is not set". Really all you have to do is get rid of that. On Thursday 22 August 2002 08:37 am, you wrote: > Hey everyone... > I'm fairly new to PHP, and this is my first post to the list. I've been > developing on the web for about 6 years now with other languages, but need > some help getting started with this one. > > > 1) This isn't working unless the form is submitted... > > if (!isset($HTTP_POST_VARS['step'])) { $step=$HTTP_POST_VARS['step']; } > > I get the error: Notice: Undefined index > > > I need to set Step=1 as default, but set Step=x when form is posted, where > x is a value from the submitted form. This to control whether or not to > show certain parts of the page. > > > > 2) Is there an easier/alternate way to default the value of a variable if > it's not already set? > > Thanks in advance, > Peter > > > > - - - - - - - - - - - - - - - - - - - - - > Fourth Realm Solutions > pbechard@fourthrealm.com > http://www.fourthrealm.com > Tel: 519-739-1652 > - - - - - - - - - - - - - - - - - - - - -

« previous php.general (#113643) next »