If I but a 'locked iPhone - locked to O2 - does that mean I can put any Pay As You Go O2 sim in the phone, and it would work?

Or does it mean that I am locked to a contract sim?

Or have I completely missed the point!?

Thanks.
Not sure whether it will be a 2G or 3G, so both