title: How to embed php script in javascript?
body: <p>I want to know if I can include <code>php</code> scripts in <code>javascript</code><a href="https://stackoverflow.com/questions/3352576/how-to-embed-php-in-javascript">[1]</a> the same way it can be done in <code>html</code><a href="https://stackoverflow.com/questions/6416418/include-php-script-inside-html">[2]</a></p>
  
  <pre><code>server.php:
  &lt;?php
      echo 'hello World';
  ?&gt;
  </code></pre>
  
  <p>client.js (or client.php if necessary):</p>
  
  <pre><code>function foo() {
      var i = &lt;?php include('server.php'); ?&gt;
      console.log( i );
  }
  </code></pre>
  
  <p>If it can be done, and if <code>client.php</code> must be used instead, I would really appreciate a minimal example with <code>index.html/index.php</code> as well, since I would like to see how I would include <code>client</code> now that it is a <code>php</code> file and not <code>javascript</code></p>