title: SyntaxError: unterminated string literal in PHP variable
body: <p>I search through the numerous questions already asked about the "unterminated string literal" syntax error but found nothing helping me ...</p>
  
  <p>So, I have this Javascript function :</p>
  
  <pre><code>function parametresModal($parametres) {
          document.getElementById('remodalTest').innerHTML = $parametres;
  };
  </code></pre>
  
  <p>Then I call this function on a link in my page :</p>
  
  <pre><code>&lt;a href="#" onClick='parametresModal("&lt;?php the_field('description-defi'); ?&gt;");'&gt;TEST&lt;/a&gt;
  </code></pre>
  
  <p>The parameter written here is simplified ; I actually want to add this Wordpress ACF's function among others and HTML markup, but I found the issue was appearing with this particular field (see below).</p>
  
  <p>This "parametresModal" function is supposed to fill the following div with its parameters :</p>
  
  <pre><code>&lt;div id="remodalTest"&gt;MyDiv&lt;/div&gt;
  </code></pre>
  
  <p>Problem is the console outputs </p>
  
  <blockquote>
    <p>"SyntaxError: unterminated string literal"</p>
  </blockquote>
  
  <p>The Wordpress ACF's field "description-defi" contains a few lines of text with some simple quotes (ex. c<strong>'</strong>est, l<strong>'</strong>éviter, ...).
  So I tried to escape the quotes with several methods :</p>
  
  <pre><code>$myField = the_field('description-defi');
  $myEscape = json_encode($myField);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>$myField = the_field('description-defi');
  $myEscape = addshlashes($myField);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>$myField = the_field('description-defi');
  $myEscape = htmlspecialchars($myField);
  </code></pre>
  
  <p>Always resulting in the same error.</p>
  
  <p>Do you see where I could be wrong in my code or my way of thinking the thing ?</p>
  
  <p>Thank you very much !</p>