Switch iPhone from t-mobile to at&t?

I want to get the newest iphone coming out very soon and my friend offered me his upgrade (very kind of him) but he has a contract with t-mobile. I was wondering if there was any way to switch my iphone from t-mobile to at&t if i were to do this, how would i do it? Is it easy or hard, any help would be appreciated

Added (1). I don't understand what you're saying. My friend has t-mobile, i have at&t. My friend has an upgrade that he is letting me use but of course the upgrade would be for a t-mobile iPhone not an at&t one, but i need to switch it to at&t because that is my carrier

You'll need to open a new line with att and ask them to port over your number from tmobile.

Then the second thing you need to factory unlock your current iphone so it will work on att.

The easiest way to unlock iphone is go to ebay and search for factory unlock iphone, you can get it done with 5 dollars.

Att line cost more than tmobile I don't know thats a good idea though.

What's the point for all these? If your friend going to give you a tmobile iphone5s, why you want to switch to att?