I have a strange situation with file_get_contents.
A webservice returns me an url, so with that url I use file_get_contents() to get the content of the file from that url.
something like:
$url = $result_from_webservice->url;
if( file_get_contents( $url ) ){
echo 'ok';
}
else{
echo 'error';
}
the result of that pice of code whas “error“.
so I have tried to set $url var directly. I have display the url result
echo $result_from_webservice->url;
from witch I have obtained the url like:
https://site.com/page.php?foo1=bar1&foo2=bar2
and then I used the direct result like:
$url = 'https://site.com/page.php?foo1=bar1&foo2=bar2';
and surprise.. that worked (result = “ok”).
then I tried to apply urldecode, thinking that my smart browser has tried to smooth the page content.
$url = $result_from_webservice->url;
$url = urldecode( $url );
but no success.
I have allowed php to print all errors and no errors, no warnings, no notice.
Do someone has an idea about what happens here and how can I solve it?
Try to cast the URL to a string before using it: