Re: if("NANC" < 0) - always evaluates TRUE...

From: Date: Tue, 06 Jan 2004 21:42:20 +0000
Subject: Re: if("NANC" < 0) - always evaluates TRUE...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-173914@lists.php.net to get a copy of this message
From: "Kelly Hallman" <khallman@ultrafancy.com> > On Tue, 6 Jan 2004, Ivo Pletikosic wrote: > > $data = 'NANC'; > > if(is_numeric($data) && $data < 0) { die('Not OK'); } > > Interesting problem, one of the first legit oddities I've seen since > joining the list. Anyway, in addition to your workaround, casting the > variable as an int also appears to result in the desired behavior: > > (int)"NANC" < 0 == false This all kind of begs the question of why you'd check if a "string" was less than zero, anyhow, doesn't it??? ---John Holmes...

« previous php.general (#173914) next »