title: What's the best practice to set html attribute via PHP?
body: <p>When doing this job in PHP,one may meet this kind of issue:</p>
  
  <pre><code>&lt;span title="&lt;?php echo $variable;?&gt;"&gt;...
  </code></pre>
  
  <p>The problem is that if <code>$variable</code> contains double quotes,should change it to <code>\"</code></p>
  
  <p>And that's not the whole story yet:</p>
  
  <pre><code>&lt;span title='&lt;?php echo $variable;?&gt;'&gt;...
  </code></pre>
  
  <p>In this case,we need to change single quotes to <code>\'</code>,but leave double quotes as is.</p>
  
  <p>So how can we do it in a general property manner?</p>