stristr() is checking a haystack for a needle. Are you sure you want something like "varcharblobint" to return TYPE_BLOB? I guess att stristr() should be replaced with strcasecmp() or with a single switch( strtolower( $type ) ) { ... instead of the if ( ... ) { ...