title: Pass PHP variables to Javascript/jquery
body: <p>So far I know two ways to pass php variables to javascript.
  One is by using </p>
  
  <pre><code>&lt;script&gt;  
        $(document).ready(function()
            phpvalue=$("#hiddeninput").val()
  
        })
    &lt;/script&gt;
  
  &lt;input type="hidden" id="hiddeninput" value="phpvalue"&gt;
  </code></pre>
  
  <p>And the other one is by having for example a button and using onclick</p>
  
  <pre><code>    &lt;script&gt;
         function clickf(phpvalue) {
  
         }
      &lt;/script&gt;
  
  &lt;input type="submit" onclick="clickf(&lt;?php echo phpvalue ?&gt;)"&gt;
  </code></pre>
  
  <p>All of them work great but:</p>
  
  <ol>
  <li><p>Is there any other way that I'm missing?</p></li>
  <li><p>Which one is the "best"?</p></li>
  <li><p>Any chance that I can use   inside the script or the external js ?</p></li>
  </ol>