Heathrow closes airside overnight and you would be forced landside. They really don't want you there either, so that would not be a comfortable experience. Airside typically reopens around 5.30am.
There are plenty of hotels along the Bath Road, a few minutes by bus from T2, and Heathrow hotel prices are normally very cheap - particularly Friday to Sunday if that happens to fit.
If the time between your flights increase to >24 hours then you would become liable for UK Airport Departure Tax (APD), which depending on your destination and cabin travelled in could be as much as £172 for long haul in Y+ or higher (or as little as £13 for a short haul in economy).