title: PHP function return value to JavaScript
body: <p>I need to send result from my PHP file to the JavaScript function/file.
  I found some of answers like: <code>var x='&lt;?php echo $pathinfo; ?&gt;';</code>
  or this:</p>
  
  
  
  <p>myHtmlFile.html:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;script type="text/javascript" src="jquery-1.8.1.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="newEmptyPHP.php"&gt;&lt;/script&gt;
  &lt;script language="javascript"&gt;
  
  function test()
  {
     alert(result);
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>newEmptyPHP.php:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
       $res="it is result";
       echo "var result = ".json_encode($res).";";
  ?&gt;
  </code></pre>
  
  <p>My question is whether there is way return value from php <strong>function</strong> and not from php file.
  something like this:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  function phpFunction(){
       $res="it is result";
       return $res;
  }
  ?&gt;
  </code></pre>
  
  <p>I need simple PHP/JavaScript code without something complex.
  I want keep many function in one php file and not many php files.</p>