FIRST TIME TRAVELER
Traveling from Phoenix AZ > London > Barcelona Spain. In London there is a 17.5 over night layover. I am planning on using this time to explore the city. Can you stay in the airport over night? Or would it be better to book a room?
You can certainly stay in the airport. A friend detailed his 24 hours that he spent in Heathrow.
Of course, whether it's better or not is up to you. You'll probably get a better night's sleep in a hotel, but some people can sleep anywhere. I've slept in a variety of airports, or at least attempted to - some are better than others. Some have quiet corners, some are crowded, and others have security stopping you sleeping there.
You can always use sleepinginairports.net as a guide for your decision, if that helps.
If you want a more comfortable stay at Heathrow there are many hotels at Heathrow airport : http://www.heathrow-airport-guide.co.uk/hotels.html