All the data on an iOS device is encrypted using strong encryption by default. The keys that are used to encrypted and decrypt our data are stored on the devices. When you choose to "Erase All Content and Settings" the device "obliterates" the keys. So your data is basically still there but no-one can read it anymore.
From the Apple's iOS Security document:
Erase All Content and Settings
The “Erase all content and settings” option in Settings obliterates all the keys in Effaceable Storage, rendering all user data on the device cryptographically inaccessible. Therefore, it’s an ideal way to be sure all personal information is removed from a device before giving it to somebody else or returning it for service.
Important: Don’t use the “Erase all content and settings” option until device has been backed up, as there is no way to recover the erased data.
I'd recommend reading through that document if you are interested in the security features of iOS devices. There's a lot more to it, including multiple levels of encryption depending on which types of data, etc.