> -----Original Message-----
> From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] 
> 
> From: "Kelly Hallman" <[EMAIL PROTECTED]>
> 
> > 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...

I have a function that returns a string on success or a negative value
on error. I was operating under the impression that php was weakly typed
but the bug.php.net entry I just did was summarily closed with the
comment "never ever compare different types like that".

So I am incorrect about what weakly typed means or something is off. In
php I indicate strong-type comparisons with === and weak with == . When
doing relative (< or > ) comparisons tho then casting is necessary or
the results are unexpected.

C.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to