Type cast encode_hex $str as string

When passing in an int, ctype_xdigit returns false, but if cast to string, it passes, as expected