[SR-Users] how can string "0" be equal to int 0?

Iñaki Baz Castillo ibc at aliax.net
Fri Oct 15 19:46:38 CEST 2010


2010/10/15 Juha Heinanen <jh at tutpro.com>:
>> No, there is no is_int function, but you could use a hack:
>>
>> if (($v == 0) && ($v + 0 == (str)0))
>>
>> will be true only if $v is int and == 0 ($v == 0 makes sure that
>> $v!="").
>
> daniel,
>
> here you go.  is that in your opinion something that a non-programmer
> could easily figure out?  if not, perhaps we should do something about
> it.

In Kamailio 1.5 I experiment this problem very often:

Usually I get data from a DB table in which some fields are INT
(allowing NULL). Possible values are NULL or integers from 0 to N.
Trying to figure if the column has value 0 is a pain.



-- 
Iñaki Baz Castillo
<ibc at aliax.net>



More information about the sr-users mailing list