The short answer is No. You cannot run PHP functions from JavaScript[With the exception of AJAX], nor can you run JavaScript functions from PHP. The two run times are separate.
How?
To understand how JavaScript and PHP cooperate, you should first understand the basics of the HTTP protocol that powers the web.
The diagram above demonstrates the basics of the HTTP protocol. The user (you) asks the client (your browser) to fetch you a page. The browser will then ask the server (Google, in this example) for the page. The server will reply with an HTML page, the client parses that page, and asks for the images, fonts and any other resources needed to load the page correctly. The client then presents the completed page to the user.
So where does JavaScript come in?
JavaScript is run in the Client (i.e. the browser). So JavaScript runs after the response from the server has arrived. Let's add that to our diagram.
JavaScript scripts start running as soon as they are loaded, and will continue to run if they have event listeners waiting for events from the user (like clicking, typing, or moving around).
Where does PHP fit in?
PHP runs on the Server, the web server (Which is a program responsible for serving web content) will run PHP according to its configuration. PHP will process the input from the web server, and return output. That output is served back to the client.
Updated diagram:
As you can see, the PHP execution does not persist. It is executed, and then ends once the response is sent.
As you can see, there is no overlap between the PHP execution and the JavaScript execution, so it isn't actually possible to make a function on one of them to work based on input from the other.
But.. but.. I've heard of AJAX!
AJAX is merely causing another HTTP request from JavaScript. You can call it a way to use PHP functions from JavaScript, but it's actually not quite that.
As you can see, with AJAX, JavaScript will send a request to the server, which will invoke PHP, PHP will run again, like in a normal request (PHP doesn't necessarily knows that this is even an AJAX request!) and the server returns the response back to JavaScript, which uses it to do stuff.
In this case, there is an overlap between the time PHP runs and the time JavaScript runs, since JavaScript invoked a request.
Also see: