Many users of iphone are struggling with iphone lock button, Only two issues regarding this lock button one is Hardware problem and other is software problem
if your iphone is in warranty then the apple is ready to replace your old mobile to new phone, Check out our iphone warranty guide to see what your rights are. You can make an appointment with the apple to find out if you’re covered. If it turns out you’re not covered, a Genius from the Apple Store will be able to tell you how much it will cost to get repair.
In iOS When buttons of your iphone stop working their is small feature which helps the issue massively, to get this feature you need to go settings > General > accessibility
There scroll down to assistive touch and slide the toggle which appears green. Now a grey square will appears on the screen, and you can drag any where you prefer on the screen. If you doudle click on that grey button you can see four buttons includes home, favorites, Device and siri. We can click on any buttons when you need.
Suppose you want to disappear this assisitive touch the only thing you need to do is disable the assistive touch, for that you need to go setting > General > accessibility > assistive touch disable.
Press that grey circle which brings up four different options as I mentioned earlier to unlock the screen you should tab the device option and tap unlock screen.