The response line
A code and a short reason, no stack trace.
The client gets a status, not the program's internals. 200 OK means the path is known and the response is ready. 404 Not Found means there is no such path. That is no reason to print a list of every route, and no reason to answer 200 with "not found" in the body: then the code and the meaning contradict each other.
In a pure function the route is an argument. In the task, '/health' answers with success and any other path with a 404. A real router looks at a table. The training one has two outcomes so the rule is visible: something unknown never becomes a success.
Do not add the time, the PHP version or a greeting to the line. The check compares the whole text. In a service, extra "friendliness" in a status breaks the client that expects a code.
On the same pattern you later add 400 for bad input and 500 for an unexpected crash. 500 is not used for "the name is empty": you have already checked that and can explain it. A 500 is for when something you did not expect broke.
Practice
An unknown path
Which response is more honest for a path that does not exist?
- 200 OK
- 404 Not Found
- an empty string
- an exception stack trace
A known path
What line does the path /health return in this task?
A response by path
Write function route($path). For /health return 200 OK. For any other path return 404 Not Found.