You can always get your iPhone repaired or replaced by Apple. Whether you have to pay for it is determined by a lot of variables. The main ones:
- Is the product newer than 12 months, or if isn't, did you purchase an extended warranty (AppleCare)? That certainly helps.
- Is it a manufacturing defect, or hardware damage caused by an Apple software update? Then Apple won't charge you for repairs, even if your phone is officially out of warranty.
- Did the product stop working correctly after something you did to it? (dropped it, banged it, froze it, fried it, took it into the shower with you, opened it up, etc etc.) Even if you did do something stupid to your phone, chances are that Apple will fix it for free.
This is my experience as well. Although Apple has a reputation as an "expensive" brand, between the low depreciation and generous support I think I've come out financially ahead of where I'd be over the years if I'd gone with the lower sticker price.
You can only get your iPhone repaired or replaced without paying if you bought AppleCare.