It's probably safe to leave food in takeout containers. The key is to store food in a shallow container that can be sealed when the food has cooled. These practices help limit bacteria.
Here's another safety tip: Don't let prepared food sit out — in your car or on the counter — for more than two hours. If you're someplace hot, where the temperature is more than 90 F (32 C), reduce that time to one hour. Bacteria can grow rapidly in food that's unrefrigerated. And some bacteria make a poison (toxin) that can make you ill, hence the term "food poisoning."
If you don't plan on eating takeout food immediately, you have two choices. You can keep it hot — internal temperature of 140 F (60 C) or higher — in an ovenproof dish in a preheated oven. Or you can divide the food into smaller portions, place it in shallow containers and refrigerate. Plan to reheat the food to a temperature of 165 F (74 C) just before serving.