1. 程式人生 > 其它 >file_get_contents()或file(): SSL operation failed with code 1

file_get_contents()或file(): SSL operation failed with code 1

技術標籤:PHP

問題:

解決:file_get_contents()或file()加入如下程式碼

$stream_opts = [
    "ssl" => [
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ]
];

$file = file('https://baidu.com',false,stream_context_create($stream_opts));