Short answer: That PHP code is run on the server before sending the response to the crawler, so by the time the page reaches the crawler, all that info is already populated.
For sites written using server-side languages such as your example, here’s the full lifecycle when a user visits a page:
The user’s browser sends an HTTP request to the server for a certain path (such as
The server receives the request and determines the appropriate server-side code to run to generate the page. It executes this code, if any (or none if it’s a static site).
The server sends the final generated, by that point static HTML page back to the user’s browser.
Note that all the code is finished running on the server before the server actually sends any information back to the user’s browser (or a web crawler).