Recent Posts

failed to open stream: HTTP request failed HTTP/1.1 400 Bad Request file_get_contents

When make request with file_get_contents sometimes we have to pass some arguments, one possible scenario is pass a string with two words including spaces. If you put the string without the proper format gives the error failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request file_get_contents.

So the solution is to apply the urlencode function for the string:

$str = urlencode("download moblileji now");
$url = "http://myurl/myfile.php?message=$str";
$string = file_get_contents($url, false); 

No comments:

Post a Comment