|
Posted by gosha bine on 04/27/07 10:16
On 27.04.2007 11:48 Jim wrote:
>> Use typecast then
>>
>> if(ctype_digit((string)$var))
>> var is an int
>>
>> or
>>
>> if(ctype_digit("$var"))
>> var is an int
>>
>> another possibility, without function calls:
>>
>> if((string)(int)$var === (string)$var)
>> var is an int
>
> Can't do that as a non-numeric string will be cast to 0 and therefore
> won't be correctly validated.
>
Exactly, it's converted to 0 and thus causes test to fail, i.e.
non-numeric string is not a number, QED.
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Navigation:
[Reply to this message]
|