PHP ini file_get_contents external url

后端 未结 7 1907
攒了一身酷
攒了一身酷 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条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 16:01

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://www.your_external_website.com");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = curl_exec($ch);
    curl_close($ch);
    

    is best for http url, But how to open https url help me

提交回复
热议问题