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