I am using a command like
$page = file_get_contents($url);
where
$url = "http://www.site.com/search/index.cfm?tab=names&workername=firstname lastname";
When the url is typed directly in the browser chrome adds a %20
in between firstname and lastname and the website handles things properly.
However when I use $url with a space, file_get_contents grabs only results that match the firstname and isn't aware that workername = "firstname lastname"
When I explicitly add "%20" in between it returns NULL
...
What's the work around?
Thanks guys!
A few problems:
?
, so no, neither of those variables will exist in $_GET
.%20
for URLs.$url = 'http://www.site.com/search/?tab=names&workername=firstname%20lastname';
^ ^ ^^^ ^
Edit:
It is possible that the website you're trying to query is ignoring them as GET variables. Have you tried adding this code to explicitly say it is a GET request?
$options = array(
'http' => array('method' => "GET", 'header' => "Accept-language: en\r\n")
);
$context = stream_context_create($options);
file_get_contents($url, false, $context);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With