The iPhone, in many ways, operates as a small computer, focusing on a variety of software and media content. In this way the device becomes well identified with the user, where their content makes up the entire usage and appearance of the iPhone. If you want to sell the iPhone, or just start over from the beginning, you will need to figure out how to clear the iPhone. This is actually a more simple process than it appears and can be done quickly so you can address the rest of your device issues or sale needs.
You start by going into Settings and then going to General, which is the top option in the third block. Here will be a lot of different options like Date & Time, Restrictions, Siri, Usage, etc. At the very bottom of this screen is going to be the Reset option, which you will select.
Inside Reset is going to be a range of different things that you can reset. This ranges from Reset All Settings, to Reset Network Settings and Reset Home Screen Layout. If your concern is to figure out how to clear the iPhone you are going to want to choose Erase All Content and Settings. This is going to remove your music, videos, apps, Contacts, text and call logs, and everything else that has been altered or downloaded to your iPhone. Once you select it the iPhone will be the same as when it was first activated.
This will not actually erase all the content that you have as this is going to be saved in a back up on your Home computer through iTunes. This will give you the option to restore most the content that is there, though some non-critical records may not be recoverable. If you want to permanently ensure that you have cleared your iPhone then you need to return to iTunes and ensure that your content will not then sync to the iPhone. The iPhone itself, however, has been cleared and is ready for sale if that is the intended purpose.