title: How to set global javascript varibles by php so the values are not public?
body: <p>I have api keys which i don't want to show in public but still i want to assign these as global javascript variable so i can access these in scripts. The api key are stored in database and available via php.</p>
  
  <p>Suppose i have the php variable <code>$key</code> which i want to assign to a global javascipt variable. Not what i do is in the head tag use this line of code.</p>
  
  <p><code>window.key = &lt;?php echo $key; ?&gt;;</code></p>
  
  <p>But that way the api keys are wide open in the head tag. I think you get the idea. Thanks!</p>
  
  <p><strong>FYI:</strong> I am working in wordpress. So, if there is any wordpress specific solution you are most welcome!</p>