Erase everything on an iPhone the right way before selling, trading in, or giving it away.
A factory reset is permanent. Run an iCloud backup (Settings > your name > iCloud > Back Up Now) so you can restore to a new phone later.
Scroll to the bottom of General to find it. This screen handles both moving to a new phone and wiping this one.
This option signs you out of iCloud and removes Activation Lock as part of the wipe — important if you're selling, or the next owner can't set it up. Don't pull the SIM or smash the phone instead; that leaves your account attached.
You'll need your Apple Account password to turn off Find My / Activation Lock. The phone reboots to the white "Hello" setup screen when it's done — that's how you know it's fully erased.