First realize that PHP runs on the server, JavaScript runs on the client (browser). PHP can only have a (more or less) direct effect on what the browser displays via the text that it outputs (be in HTML, JavaScript, or XML), which the browser then interprets and visually renders accordingly.
However, there is a capability within JavaScript to send HTTP requests for a web page, including PHP pages, receive the result from that request, and then change the page rendering as desired based on the response. This is generally referred to as "AJAX", making it sound like something separate, but ultimately is really just the use of a few JavaScript functions in conjunction with whatever you want it to call on the server.
Do some Googling on "AJAX and PHP" and you should find all sorts of tutorials, explanations, along with the usual junk and bad advice you normally find on the web. 😉