title: What is the safest way of passing arguments from server-side PHP to client-side JavaScript
body: <p>In my application I rely heavily on JavaScript to enhance the user interface, but all of the data comes from a database and is processed by PHP. By default I use 'echo' statements to substitute the required values "just in time" like so:</p>
  
  <pre><code>var myVariable = &lt;?php echo $myVariableInPHP ?&gt;
  </code></pre>
  
  <p>This, however, does not strike me as very elegant and I am concerned about stability and maintainability of such code.</p>
  
  <p>Do I have any alternatives here? </p>
  
  <p>For server-side, I am using the Symfony 1.4 PHP framework.</p>
  
  <p>Thanks,</p>