title: PHP urlencode not working as intended
body: <p>I have a URL with space characters that I want to properly encode when making an API call (in this case replace ' ' with '%20' so the space characters are treated properly.</p>
  
  <pre><code>$url = 'https://www.someapi.com?param=this and that';
  </code></pre>
  
  <p>Hoever when using the urlencode($url) function I get this obscure representation of the URL</p>
  
  <pre><code>"https%3A%2F%2..."
  </code></pre>
  
  <p>That I eventually cannot resolve.</p>
  
  <p><a href="https://i.stack.imgur.com/qvS1r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qvS1r.png" alt="enter image description here"></a>........</p>
  
  <p>Is there a URL-encode function in PHP that just replaces spaces and quotation marks instead of making abrupt changes to the whole string?</p>