Can I put a pay as you go SIM card in a locked iPhone 3GS?

Can I put a pay as you go SIM card in a locked iPhone 3GS?

If it's locked it will be because the previous owner had a contract, you would have to find out with which company it was with and get that company's pay as you go sim. Or you could pay to have the phone unlocked at a phone shop that does it, not Carphone Warehouse or any of them, there are normally shops like this in your local shopping centre.

It would have to be from the same carrier the phone is locked to now.