吃了吗? literally means “Have you eaten?” In daily Chinese, it can also work like a warm check-in, especially because food is closely connected to care, comfort, and everyday relationships. But it is not a universal “hello.” If you use it with the wrong person or at the wrong time, it may sound like you are really asking about food.
Use 吃了吗? when three things are true: you already know the person, the situation is casual, and it is close to mealtime. It sounds natural with neighbors, relatives, friends, familiar colleagues, or people you often see. I would not use it with a stranger, in a formal first meeting, or at a random time like 10 a.m.