Home php file_get_contents: function not working

file_get_contents: function not working

Author

Date

Category

Hello, I made a parser for the site, but gave me an error a couple of days ago

Warning: file_get_contents (http://mySite.ru/) [function.file-get-contents]: failed to open stream: Connection refused in /var/www/site.ru/data/www/ site.ru/informer/go.php

/ **** part of the code ***** /
$ url = "http://cbu.uz/";
$ content = file_get_contents ($ url);

Function file_get_contents () whichever site you enter, everything will return an error.


Answer 1, authority 100%

Learn to read error messages.

failed to open stream: Connection refused in


Answer 2


Answer 3


Answer 4

php.ini has an option allow_url_fopen . Make it On. If you don’t have access to php.ini, try creating a .htaccess file in the root of the site and add it there:

php_flag allow_url_fopen 1

Answer 5

Hello everyone, file_get_contents did not work for me, that is, it did not display anything at all, the variable where I wrote my file was empty, I looked at the code for errors, checked if this function was enabled in php.ini, but purely by accident decided to specify a different path instead of https://domen.ru/file.txt , I specified the full local path , that is, /var/www/xxxxxx/data/www/domen.ru/file.txt, everything worked for me.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions