My only experience of having an iPhone actually shutdown due to excessive heat was when using it as a satnav on a very hot day. I solved that problem by switching to a cradle that sits it in front of the air-con.
Basically anything that that puts a strain on the processor will cause the phone to heat up and if the ambient temperature is high, it'll heat up even more.
Although I've not experience it, using your phone while charging can also cause it to overheat and I would steer clear of third-party chargers.
My phone has gotten really hot when I've accidentally left an app open and didn't put my phone to sleep. Sometimes the app will keep my phone screen on.
I've never had my iPhone overheat, to me it sounds like there could be a design flaw in the phone itself or sometimes people forget to close apps when they're done with them. That still shouldn't cause the phone to overheat, if anything that would just drain your battery a bit faster. If you play games for hours on your phone in general, it can cause it to overheat.