How does PHP work with Java?

1 Answer

Relevance
  • Chris
    Lv 7
    4 weeks ago

    I assume you mean JavaScript, which is a completely separate language used primarily inside the browser (exclusively so in the context of a PHP website).

    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.

Still have questions? Get your answers by asking now.