Nope, this is a common misconception, and one the mobile phone companies aren't keen to dispel. It's important to make the distinction between unlocking and unblocking. Unlocking, which lets you use your phone, usually instantly, with any Sim card from any network is completely legal.
Unblocking is enabling a phone to work when it's been rendered unusable after being reported lost or stolen. This is completely illegal and should not be attempted.
Simply Key *#06# to find your "IMEI" needed for unlocking, this may also be found on the battery of your phone.
*Dial 0906 575 3606
And type your “IMEI’ code to obtain your unlock code.
Enter the instantly generated code and your mobile phone/cellular will be unlocked!!
*Calls charged at £1.50 per minute from BT landlines at all times. Calls from mobiles may vary. Over 18s only. Get bill payers permission. Please read terms of service before your call - Unlock your Mobile Phone.