Search code examples
phpurlcurlformatglob

How do I avoid URL globbing with PHP cURL?


I have a url (slightly modified) like so:

https://ssl.site.com/certificate/123/moo.shoo?type=456&domain=$GH$%2fdodo%20[10%3a47%3a11%3a3316]

It doesn't work the way I intend it to when passed straight through to PHP cURL because of the brackets.

I managed to run the same URL successfully in the command line like so:

curl -g "https://ssl.site.com/certificate/123/moo.shoo?type=456&domain=$GH$%2fdodo%20[10%3a47%3a11%3a3316]"

Is there an option (similar to -g, for disabling globbing) that I can use in PHP cURL? If not, how should I encode or format my URL before passing it to PHP cURL?


Solution

  • Currently I'm using this and it seems to work

    $urlReconstructed = str_replace(']', '%5D', str_replace('[', '%5B', $url));