title: How to pass an integer value to JS that is in a PHP integer variable?
body: <p>I'm trying to pass some variables from PHP to JS.</p>
  
  <p>I saw <a href="https://stackoverflow.com/questions/5174241/passing-a-string-variable-from-php-to-a-js-function" title="passing a string variable from php to a JS function">here</a> that for strings the following code would work: </p>
  
  <pre><code>    var str = "&lt;?php echo $x; ?&gt;";
  </code></pre>
  
  <p>I've been using this:</p>
  
  <pre><code>    var var1 = &lt;?= $var1 ?&gt;;
  </code></pre>
  
  <p>Which one should I use for int? the first version is always good? Is the second one just an old form? I'd be happy for a clarification and instruction on passing variables (dif types) from php to js in general.</p>
  
  <p>Thanks!</p>