How to Shut Off an iPhone When the Button Is Broken
The power button on an Apple iPhone is located on the top edge of the phone, near the left side of the device. The switch that controls this power button is extremely tiny inside the phone and it can become unresponsive. If the power button no longer works on your iPhone, you may not be able to power the phone off. You can always power an iPhone on by plugging it into a USB cord connected to a computer with iTunes. Thankfully, there are a few known tricks to persuade a recalcitrant power button to operate.
Wait until the device runs out of battery power and it will power off on its own. This is perhaps the easiest method to power off an iPhone when the power button is broken, although it may require waiting a few days. You can power the device on again simply by plugging it into a computer with the USB cable.
If you have AppleCare or the iPhone is still under warranty, take it to an Apple retail store or call AppleCare for assistance. A broken power button is covered by the Apple warranty, so if your phone won't power off you can get help from Apple to fix the device.
Squeeze the edges of your iPhone near the top of the device, just below the power button, and press the power button at the same time. This method may force the internal switch to make just enough contact to allow you to power it off. Eventually this method may not continue to work, as the internal damage grows worse every time you exert additional pressure on the switch, but it may work in a pinch.