Posted by Jim on 04/27/07 09:48
> 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.
Jimmy.
Navigation:
[Reply to this message]
|