The standard troubleshooting steps are Restart and Restore. The symptoms you describe might also be the result of not having enough free storage space. Check Settings > General Storage & iCloud Usage.
Otherwise, make a backup and take to an Apple Store or an authorized iPhone service center to have its hardware tested.