Why did I get a 400 Bad Request when getting a page with PHP Curl?
- by user307272
Hi, I was trying to access a page using curl. I could access it perfectly using the browser and using "static" strings as the URL, like:
$url = "http://www.example.com/?q=1234"
But when I tried to access the page using a variable in the URL string like:
$url = "http://www.example.com/?q=$param"
I got a 400 error code. I checked out on the web and found some comments here in this stackoverflow thread:
Then, just for curiosity I did the following:
$url = "http://www.example.com/?q=" . trim($param);
and it worked! And no, $param did NOT contain any spaces.
To me, it seems that it can be some encoding error, but I really can't find an explanation for it. Does anyone here in stackoverflow know what it can possibly be?
Thanks in advance :)