It does it automatically. PHP is a server-side scripting language, not a client-side markup language like HTML or client-side scripting language like Javascript. You never see PHP code because it's processed on the server before it ever gets to the browser. PHP outputs HTML... so what you're actually seeing is the output that the PHP generated on the server.
Basically, what happens is this:
1) Browser requests content for index.php
2) Server looks for index.php and runs the code in the file.
3) Server sends the result of running the code (which, usually, is a string of HTML code) to the browser.
4) Browser reads the HTML and displays the web page.