Can this happen to an iphone?

I was having problems with an iphone 5c overheating and the camera quit working. I took it to an repair place. They took the phone apart and said it was dirty inside. They cleaned it. Now the phone isn't hot and the camera works again. Has this ever happened to anyone before?

Yes.

I highly doubt it was dirty inside and that was the problem, but either way it doesn't matter as they fixed it, so they did what you paid them to do and all is well.

Its possible. Though iPhones don't have any ventilation ports I know of in similar cases for most electronics these days they have ports/vents that need to be cleaned from time to time to prevent overheating & eventual failing of components.