I've noticed a few illiustrations of walled cities showing green space inside their walls, and I'm just wondering if this is simply because we have incomplete archeological records.
I can't speak for all time periods but city walls were a challenging undertaking for many cultures. They were necessary for defending your city but also were expensive and hard to plan because cities expand. In many cities there might have been private parks and small estates but for the most part the area around the city was farm land and would therefore have been a sharp contrast to the verdant countryside in the urbanized city. City walls also need to be defendable and the bigger you make the walls the more wall you need to defend.
Dura-Europos in Syria has one of the oldest synagogues in the world. It is so well preserved because it was close to the western side of the city and when the city was under attack they filled in the building and the surrounding area to reinforce the walls. This suggests that this building must have been fairly close to the outer wall or else they would not have used existing buildings. Whether this means it was intentionally placed near the city walls or the city crept outwards towards the wall is hard to say.
The nature of city walls was also mutable depending on where you were building them. Athens for example built walls that went around their city and all the way down to their port because protecting Athens meant also protecting its access to the Mediterranean, this was especially true because their enemies in The Peloponnese Wars tended to have fantastic land armies but couldn't match up with their navy. The city walls extending that far gave them the ability to defend on land and launch naval expeditions to undefended areas and force the invading army to return home.
I am not sure that actually answered your question, but hopefully it helps.