title: PHP: convert spaces in string into %20?
body: <p>How can I convert spaces in string into <code>%20</code>?</p>
  
  <p>Here is my attempt:</p>
  
  <pre><code>$str = "What happens here?";
  echo urlencode($str);
  </code></pre>
  
  <p>The output is <code>"What+happens+here%3F"</code>, so the spaces are not represented as <code>%20</code>.</p>
  
  <p>What am I doing wrong?</p>