More than likely its a corrupt software issue. Start by terminating all apps that are suspended in the background and turn your phone off. Leave your phone off for 30 seconds turn it back on and see if that corrects the issue. If not, the next option is to restore your phone to factory (please make sure you backup your phone before you do this because you will lose everything). Once you have backed up your device, and then restored it two options will appear in itunes: 1. Set up as a new phone, 2. Restore data from an old backup. Chose the option that states setup as a new phone. If you choose restore from an old backup you could bring the old problem right back on your phone.
You should then be able to see if wifi works. If it does, you're all set, if not, you may need a new phone and should make an appointment at your local Apple Store: http://www.apple.com/retail