title: Escaping single quotes in a URL link
body: <p>I have a link that is sent throw some PHP code:</p>
  
  <pre><code>echo "&lt;a href='" . $galerry . "#" . apastro(get_title($primid)) . "'     class='linkorange'&gt;voir sa galerie&lt;/a&gt;";
  </code></pre>
  
  <p><code>$galerry</code> links to another page.</p>
  
  <p><code>get_title($primid)</code> is the id of a specific element in <code>$galerry</code> page.</p>
  
  <p>And the mechanism works fine until one of the elements id has a single quote in it. Which makes sense as it would interrupt the echo function.</p>
  
  <p>This is why I have the apastro function:</p>
  
  <pre><code>function apastro($phrase){
      $phrase1 = str_replace("'", "\'", $phrase);
      return $phrase1;
  }
  </code></pre>
  
  <p>Yet, the <code>\</code> before the single quote isn't helping...</p>
  
  <p>So let's say the link redirects to the element with id="l'aro" on the page <code>something.php</code>. Then the URL will be <code>something.php#l\</code>.</p>