PHP is a server side programming language, which is ran into the web server when a page is generated, before being sent to the browser.
Javascript is a client side scripting language, that run into the browser, and is allowed to interact with the element that are present into the page.
PHP run only during the page load. Once the page is loaded, no more PHP can be run.
Javascript starts only when the page is received. For more information check out
web application development