Link: Hard-locking an iPhone
Great tip from John Gruber, and something all iPhone users should know:
The first is hard-locking. When you hard-lock your iPhone or iPad, it enters a mode that requires the device passcode to unlock. With recent iPhones and iPads, you enter this mode the same way that you turn off the device: by pressing and holding the power button and either of the volume buttons for about two seconds.
[On iPhone 8 and later] you can also do the same thing by quickly pressing the side button alone five times.