Your example works for me. What is the error-message you’re getting? In order to open a URL with file_get_contents(), the allow_url_fopen option must not be false in the php.ini. If you’re running this on some shared hosting server, your provider might have disabled this. Care to post the error-message?
I am executing it in “000webhostapp.com” it does not show me any error when I debug it with print_r (file_get_contents), but in the local server it shows all the content,
It is as if openstreetmap were blocking the requests from this host, I say this because from other pages if the normal content arrives with that same code