The same system rarely interprets PHP and HTML, it does either or.
It's a little hard to guess what exactly you're talking about, but I'm assuming you're talking about a file like this:
<html>
   ...
   <?php echo 'foo'; ?>
   <p><?php echo 'bar'; ?></p>
   <script type="text/javascript">
       alert('baz');
   </script>
</html>
In this case, each "language" is handled by a different system entirely.
- The client sends an HTTP request to the web server.
- The web server fires up PHP.
- PHP interprets and runs all <?php ?>snippets (from top to bottom) and completely ignores anything else.*
- The web server returns the processed file to the client, which now does not contain <?php ?>snippets anymore. It returns whatever PHP spit out after it was done.
- The client parses the HTML to visually build a website out of it.
- Once the HTML is parsed, the <script>snippets are executed by the client's Javascript implementation, if it has such a thing.
A visual reminder, taken from https://stackoverflow.com/a/13840431/476:
                    |
               ---------->
              HTTP request
                    |
+--------------+    |    +--------------+
|              |    |    |              |
|    browser   |    |    |  web  server |
| (Javascript) |    |    |  (PHP etc.)  |
|              |    |    |              |
+--------------+    |    +--------------+
                    |
  client side       |      server side
                    |
               <----------
          HTML, CSS, Javascript
                    |
* By "ignore" I mean it just passes it right through as output, it does not interpret it as PHP code.