title: Why am I getting Illegal Token when outputting JavaScript from PHP?
body: <p>I am trying to output Google Translate code from PHP (wordpress plugin) to the page and it is giving me Illegal Token errors even though when I paste the exact same line of code directly into the console and run it, it works. </p>
  
  <p>Here is my PHP:</p>
  
  <pre><code>    function AddTranslateSidebar(){
    echo "&lt;script&gt;
      jQuery(document).ready(function(){
        gt = escape('&lt;div id=\"google_translate_element\"&gt;&lt;/div&gt;&lt;script type=\"text/javascript\"&gt;function googleTranslateElementInit() {new google.translate.TranslateElement({pageLanguage: \"en\", layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, \"google_translate_element\");}&lt;/script&gt;&lt;script type=\"text/javascript\" src=\"http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit\"&gt;&lt;/script&gt;');
        jQuery('#sidebar').prepend(unescape(gt));
      });
    &lt;/script&gt;";
  }
  </code></pre>
  
  <p>That code outputs the following into the page as HTML/JavaScript:</p>
  
  <pre><code>&lt;script&gt;
      jQuery(document).ready(function(){
        gt = escape('&lt;div id="google_translate_element"&gt;&lt;/div&gt;&lt;script type="text/javascript"&gt;function googleTranslateElementInit() {new google.translate.TranslateElement({pageLanguage: "en", layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, "google_translate_element");}&lt;/script&gt;&lt;script type="text/javascript" src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"&gt;&lt;/script&gt;');
        jQuery('#sidebar').prepend(unescape(gt));
      });
    &lt;/script&gt;
  </code></pre>
  
  <p>Which causes the error </p>
  
  <pre><code>Uncaught SyntaxError: Unexpected token ILLEGAL 
  </code></pre>
  
  <p>On the gt = escape( ... ); line.</p>
  
  <p>However, if I copy that code directly from the HTML source using the inspector and then paste it into the console and run it, it works and the translate dropdown shows up. </p>
  
  <p>Why is this happening?</p>
  
  <p>Thanks.</p>