This is my code:
file_put_contents('ip.txt', $ip); // ip is 62.227.217.95 and is saved correctly into ip.txt file
$returned_content = get_data('https://xxx:[email protected]/geoip/v2.1/city/' . $ip);
file_put_contents('content.txt', $returned_content); // file is empty, nothign saved
You can see what's the problem in the comments.
BUT when I put the ip directly instead of from GET parameter:
file_put_contents('ip.txt', $ip); // ip is 62.227.217.95 and is saved correctly into ip.txt file
$returned_content = get_data('https://xxx:[email protected]/geoip/v2.1/city/62.227.217.95');
file_put_contents('content.txt', $returned_content); // content is written correctly, everything fine.
What am I doing wrong here? I also tried urldecode($ip)
Please help
There were invisible chars, I solved it with: preg_replace('/[\x00-\x1F\x7F]/u', '', $ip)