Re: Default values

From: Date: Mon, 19 May 2003 21:09:54 +0000
Subject: Re: Default values
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148211@lists.php.net to get a copy of this message
I have a nice little function for this. function alternate(&$a, $b) { return ( $a = ( $a ? $b : $b ) ); } this will work as long as you know what you should be expecting. <?php function alternate(&$a, $b) { return ( $a = ( $a ? $b : $b ) ); } alternate($_POST['query'], ''); $select = "SELECT * FROM table WHERE colName='".$_POST['query']."'"; ?> this would normally cause an error that would stop the script, but since you have defined the value of $_POST['query'] to something( be it blank) that it will now not give you an error. Have fun with it... :) Jim Lucas ----- Original Message ----- From: "Sano" <sano@szm.sk> To: <php-general@lists.php.net> Sent: Saturday, May 17, 2003 2:01 PM Subject: [PHP] Default values > Greetings, > what would I have to do to initialize all possible variables with a default > value... > > Like any variable name given will return a integer "-1" ??? > > possible? > > mail me please. > sano@szm.sk > > thanx > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#148211) next »