PHP ini file_get_contents external url

后端 未结 7 1886
攒了一身酷
攒了一身酷 2020-11-22 15:28

I use following PHP function:

file_get_contents(\'http://example.com\');

Whenever I do this on a certain server, the result is empty. When I do

7条回答
  •  -上瘾入骨i
    2020-11-22 15:56

    The setting you are looking for is allow_url_fopen.

    You have two ways of getting around it without changing php.ini, one of them is to use fsockopen(), and the other is to use cURL.

    I recommend using cURL over file_get_contents() anyways, since it was built for this.

提交回复
热议问题