RE: [PHP] Argh! nulls un stuff..

From: Date: Mon, 14 Oct 2002 14:16:53 +0000
Subject: RE: [PHP] Argh! nulls un stuff..
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-119896@lists.php.net to get a copy of this message
if( !empty($_SESSION["temp"])&& is_numeric($_SESSION["temp"]) && $_SESSION["temp"] >= 0 ) { ... } Something like this may work, first check to see if its not empty, then numeric, then if its greater than or equal to 0. If all three conditions are true then it'll execute the "..." block. Please note that this code has not been tested and is prone to typos. :) Matt > -----Original Message----- > From: Francis [mailto:news@radnip.com] > Sent: Monday, October 14, 2002 9:23 AM > To: php-general@lists.php.net > Subject: [PHP] Argh! nulls un stuff.. > > ok going mad all I need to do is check a variable and if it has a number > in > it then do something, so anything from 0 up, but it keeps thinking 0 is > null > and failing, anyway around this? or am I just being stupid as usual? > > $_SESSION["temp"] = 0; > $tempVar = 0; > > if($_SESSION["temp"] !=""){ echo "!= condition<br>"; } > if(isset($_SESSION["temp"])){ echo "isset condition<br>";} > if(isset($tempVar)){ echo "tempVar isset condition<br>";} > if($tempVar !=""){ echo "tempVar != condition<br>";} > if(!empty($tempVar)){ echo "tempVar !empty condition<br>";} > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.399 / Virus Database: 226 - Release Date: 10/9/2002 > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.399 / Virus Database: 226 - Release Date: 10/9/2002

« previous php.general (#119896) next »