title: How can I call PHP functions by JavaScript?
body: <p>I am trying to call a PHP function from an external PHP file into a JavaScript script. My code is different and large, so I am writing a sample code here. </p>
  
  <p>This is my PHP code:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  function add($a,$b){
    $c=$a+$b;
    return $c;
  }
  function mult($a,$b){
    $c=$a*$b;
    return $c;
  }
  
  function divide($a,$b){
    $c=$a/$b;
    return $c;
  }
  ?&gt;
  </code></pre>
  
  <p>This is my JavaScript code:</p>
  
  <pre><code>&lt;script&gt;
    var phpadd= add(1,2); //call the php add function
    var phpmult= mult(1,2); //call the php mult function
    var phpdivide= divide(1,2); //call the php divide function
  &lt;/script&gt;
  </code></pre>
  
  <p>So this is what I want to do.</p>
  
  <p>My <strong>original</strong> PHP file doesn't include these mathematical functions but the idea is same.</p>
  
  <p>If some how it doesn't have a proper solution, then may you <strong>please</strong> suggest an alternative, but it should call values from external PHP.</p>