If you suspect that the power button is faulty, you can try the following options:
Restart your iPhone by connecting it to a power source.
Use the "AssistiveTouch" feature to access the power off slider without using the physical power button. You can enable this feature in Settings > Accessibility > Touch > AssistiveTouch.
Contact Apple Support or visit an authorized service center for further assistance.