Welcome to iMore! Do you mean the 4digit passcode to open the phone? If so, the only way is to connect the phone to iTunes on computer and put it in DFU mode and restore. But to set up afterwards, you will still need the Apple ID and password. And all data will be lost, including photos.