title: Convert Quotes Using htmlspecialchars AND Keep HTML Tags in PHP
body: <p>I have a hidden input tag that I want its value to have quotes in it. How would I escape the quotes so that I can use it for the value?</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;input type="hidden" name="edited_terms" 
  value="&lt;p&gt;\"Please enter any additional terms and conditions here.\"&lt;/p&gt;" /&gt;
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>$terms = mysql_real_escape_string($terms);
  echo '&lt;input type="hidden" name="edited_terms" value="'.$terms.'" /&gt;';
  </code></pre>
  
  <p>I would like to use both single and double quotes, however setting it to <code>value='&lt;p&gt;\"Please enter any additional terms and conditions here.\"&lt;/p&gt;'</code> won't let me use single quotes.</p>
  
  <p>The function <code>htmlspecialchars</code> let's me accomplish this but it will get rid of HTML tags. For example, <code>&lt;p&gt;</code> will be converted to <code>&amp;lt;p&amp;gt;</code>. I want to be able to keep the <code>&lt;p&gt;</code> tags and convert the quotes to <code>&amp;quot;</code>.</p>