Many cellular providers around the world lock their phones so that they cannot be used on the networks of other providers. Unlocking codes remove the lock and make the phones usable on any other network that utilizes the same type of technology.
Phones that are locked to specific carriers use devices called Subscriber Identification Module (SIM) cards that are provided by the carrier at the date of activation. Only phones on a Global System for Mobile communications (GSM) network use SIM cards. GSM is a standard that was started by the European Conference of Postal and Telecommunications Administrations in 1982, adopted by over a dozen European countries in 1987, and then finalized in 1989. GSM is now the most used typed of cellular network in the world.
A locking code prevents a phone from working unless it is using a SIM card from a specific company. The lock forces customers to purchase only phones and SIM cards from their cellular carrier or from specific manufacturers. Phone locking codes can also work as a security measure by preventing thieves from using a stolen phone if they are trying to use a SIM card from a different cellular carrier.
There are no laws covering locking codes for mobile phones in the United States, Spain, and the UK, so each GSM company in those countries has vastly different policies regarding them. Both Singapore and Belgium have outlawed phone locking codes and France has laws in place that compel cellular carriers to provide the unlocking code to their customers once they have only six months remaining in their service contract.
You can acquire an unlocking code for your GSM phone in several different ways. The most common method available is to contact your cellular provider's local office and ask for a code that you enter directly into the phone's settings menu. You can also call your cellular provider's customer service office and have them send an over-the-air update that automatically unlocks the phone. A few companies also offer services that allow you to mail in a phone so that their technicians can enter the unlocking code and then mail it back to you.
Cellular providers in the United States are not required to give you an unlocking code, so many only offer them under specific circumstances, such as if you move out of their coverage area or your service contract ends. You can also obtain unlocking codes for certain types of phones from other sources such as websites or third party phone companies.