What does it mean when an iPhone is locked to a network?

I'm looking to buy a second hand iPhone 4 however it says it is currently locked to o2, What does it mean? I'm looking to buy a pay as you go iPhone

It means you can only use O2 sim cards in the phone, and it won't work with any other network.

You can get phones unlocked by either searching for a code online or paying a shop to do it. Where I live they charge from £5 to £10.

It means that the phone will only work with an O2 sim card, but tech shops can usually unlock it very cheaply, so that it will work with any network, hope this helps! (^ω^)

It means that the network its locked to is the only network it works with
answer mine?