Iphone lock button doesn't work?

It randomly didn't work. So when i press on it the screen won't turn offf help!

So you were expecting an apple product to not make you have to buy a new one?

The fix was really simple and involves invoking a new 'Gesture' which made a small virtual button appear on the iPhone screen. To access it, head into Settings > General > Accessibility > Assistive Touch and toggle it to 'On'. Hit Create New Gesture and a small white button will appear permanently on your screen, until you turn it off of course.

The button gives you a virtual Home button, and if you select Device, then you can Lock the Screen, control volume, shake the device, rotate the screen etc. You can also position it in several areas around the screen i.e. Move it to an innocuous location on the screen. The catch is, if your lock button is completely broken then you can't allow your device to power off. However, the virtual button will allow locking which is pretty much what you want.