How does PHP work with Java?
- ChrisLv 74 weeks ago
The website server's PHP and the in-browser JS code don't communicate directly but via HTTP requests.
A basic example of JS working with PHP would be a <form> where the user can signup. You can write an input event listener for the <input> where the user enters their desired username, and inside the listener run a request for, say, "/api.php?action=username_free&val=" + val;
The script api.php on the server reads $_GET['action'] and $_GET['val'] and sends back information accordingly.
The JS in the browser receives the reply and can show/hide a "username already taken" notice, *while the user is typing*.
That's how PHP works with JS.