If you're thinking about selling your iPhone, you want to make sure the new owner doesn't have access to everything linked up to your account. This quick guide will run you through how to wipe all data from your iPhone and restore it back to it's factory default settings.
First things first, before you wipe your iPhone clean, make sure you've got everything you need backed up. If you're moving over to another Apple phone then this is as easy as doing a back up in iTunes or with iCloud, but if you're moving away from Apple then you might need to use other techniques to export some of your data. Mashable have done a useful graphical guide to exporting your contacts and then importing them into Google.
Your phone will restart and then be restored to it's original factory settings (this may take a few minutes). You should also receive an email letting you know that 'Find my iPhone' has been disabled if you had it switched on.