title: Pass PHP variable on OnClick method
body: <p>I already tried all the methods i saw here in Stackoverflow but im getting errors.</p>
  
  <p>Im trying to pass a php variable value to a javascript function, im trying to do both methods:</p>
  
  <pre><code>echo '&lt;td&gt;&lt;a href="#" onclick="delete('.$contact['idContact'].')"&gt; Delete &lt;/a&gt;&lt;/td&gt;';
  </code></pre>
  
  <p>This method above thinks the value of the idContact is actually a variable, so he is trying to get the value of the variable "105" (the value of idContact) </p>
  
  <pre><code>echo '&lt;td&gt;&lt;a href="#" onclick="delete("'.$contact['idContact'].'")"&gt; Delete &lt;/a&gt;&lt;/td&gt;';
  </code></pre>
  
  <p>This method gives me </p>
  
  <pre><code>Uncaught SyntaxError: Unexpected token }
  </code></pre>
  
  <p>What is the correct way to do it? Thanks in advance.</p>
  
  <p>Here is a simple code to show my problem:</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;
  &lt;script&gt;
  
  function eliminate(test)
  {
      alert(test);
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;?
  
  $test = "name";
  
  echo '&lt;a href="#" onclick="eliminate('.$test.')"&gt; Delete &lt;/a&gt;';
  
  ?&gt;
  
  &lt;/html&gt;
  </code></pre>