Re: Argh! nulls un stuff..
| From: | Maxim Maletsky | Date: | Mon, 14 Oct 2002 13:39:08 +0000 |
| Subject: | Re: Argh! nulls un stuff.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-119882@lists.php.net to get a copy of this message | ||
$var = 0;
if(!is_int($var)) {
echo '$var isn\'t numeric';
}
and simple 'not' is going to ignore '0'. To check wherther a value is an
integer use is_int() or is_numeric(), which are the same things anyway.
If you care that the value is also higher than '0' add [ and $var>0] as
the second condition.
Maxim Maletsky
On Mon, 14 Oct 2002 14:23:00 +0100
"Francis" <news@radnip.com> wrote:
> 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
>
--
Maxim Maletsky
maxim@php.net
www.PHPBeginner.com // where PHP Begins