title: How to read PHP variable from JavaScript?
body: <p>I know that there are many questions about this but I cannot make it work.</p>
  
  <p>My HTML (test.htm) has only this code</p>
  
  <pre><code>&lt;?php
  $var = 'foo';
  ?&gt;
  &lt;script type="text/javascript" language="javascript"&gt;
  var val = "&lt;?=$var?&gt;";
  alert(val);
  &lt;/script&gt;
  </code></pre>
  
  <p>But when I open the file with the browser the value of val is <code>"&lt;?=$var?&gt;"</code>  and not 'foo'</p>
  
  <p>How can I make it work?</p>