Your phone doesn’t like extreme heat any more than you do. You might see a warning on your screen if your phone gets so hot that it stops working well. If this happens, don’t stick your phone in the fridge.
Try grabbing something cold, such as a freezer pack or a bag of frozen vegetables, and wrap it in a dish towel. Put your phone on the towel for about a minute, then check if your device is working. Repeat until the phone is back to working condition.
Also, don’t leave your phone or other electronics in your car or exposed to direct sunlight when it’s this hot outside. Even the trunk or glove compartment might be too toasty.