All the PHP in a page runs before any of the Javascript.
The server receives a request for a page.
The server runs the PHP script to generate a response.
The server sends the response back to the client.
The client receives the response and runs any Javascript it finds in it.
So the server doesn't do anything with the Javascript, and the client doesn't do anything with the PHP (it doesn't even see the PHP).