This article explains how to turn the screen lock on and off on devices running iOS 4 and later. It's broken down by iOS version and covers ways to tell if the screen lock is enabled.
ALL iPhoneS: HOW TO TURN SCREEN ROTATION ON OR OFF
What if you don’t want your iPhone screen to rotate when you change the position of your device? Then you’ll need to use the Screen Rotation Lock feature built into iOS (this tip also applies to iPhone, iPad, and iPod touch). Here’s what to do:
Swipe up from the bottom of the screen (or swipe down from the top-right corner on iPad and iPhone X and later) to reveal the Control Center.
The location of the screen rotation lock depends on which iOS version you are using.