PHP file_get_contents does not work on localhost

前端 未结 7 1182
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 21:48

I am working on my website from localhost (http://172.16.65.1/) a MAMP server on OSX.
I want to load some JSON from Google and some simple tests show me I have a probl

相关标签:
7条回答
  • 2020-12-01 22:37

    From the documentation for file_get_contents:

    A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

    Check in your php.ini so allow_url_fopen is set to on.

    EDIT:

    I didn't noticed that you actually could use file_get_contents locally, so now I'm thinking that this could have something to do with your firewall settings.

    Also, try to set the user_agent in your php.ini if not already done.

    0 讨论(0)
提交回复
热议问题