title: How to send a normal variable's value from PHP to JavaScript?
body: <p>I have the below piece of code in my <code>test.php</code> file. The code mainly has a variable defined in PHP, and I want to send it to a JavaScript function so it could POST it. Here's the code :</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;title&gt;Payment Receipt&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;?php
  ...
  if($row) {
      $myValue = 'Hi there!'; //the PHP variable (currently has a sample value, but will be string only)
  
      //JS starts    
  
      echo &lt;&lt;&lt;JS001
      &lt;script type=&quot;text/javascript&quot;&gt;
      var msg = {$myValue}; //trying to set it to a JS var, so I could send it to below function.
      var ThunkableWebviewerExtension = {
          postMessage: function (message) {
              if (window.ReactNativeWebView) {
                  window.ReactNativeWebView.postMessage(message);
              } else {
                  window.parent.postMessage(message, '*');
              }
          }
      };
      
      ThunkableWebviewerExtension.postMessage(msg);
      console.log(msg);
      alert('Message Sent');
      &lt;/script&gt;
  JS001;
      
  } else {
      echo 'Incorrect Value';
  }
  
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>But when I run this code, I get this error on console : <code>Uncaught SyntaxError: Unexpected identifier</code>. What should I do if I want to send just a simple string value to the JS code? What's wrong currently?</p>
  <p>Any help is appreciated! Thanks!</p>