Because gettype() is not the function to use.
Did you read this warning in the manual?:
"Never use gettype() to test for a certain type, since the returned string may be subject to change in a future version. In addition, it is slow too, as it involves string comparision .
Instead, use the is_* functions."