小编cod*_*exy的帖子

PHP - get_headers和SSL的错误

这是我的代码

$url = 'http://www.wikipedia.com';  // URL WITH HTTP
$hurl = str_replace("http", "https", $url); // URL WITH HTTPS

$urlheads = get_headers($url, 1);   
$surlheads = get_headers($hurl, 1);     
$urlx = false;
$surlx = false;

foreach ($urlheads as $name => $value) 
{
    if ($name === 'Location') 
    {
        $urlx=$value;   
    }
    else{

    }
}
print_r($urlx);
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

Warning: get_headers(): Peer certificate CN=`*.wikipedia.org' did not match expected CN=`www.wikipedia.com' in....

Warning: get_headers(): Failed to enable crypto in....

Warning: get_headers(https://www.wikipedia.com): failed to open stream:     operation failed in .....
Array ( …
Run Code Online (Sandbox Code Playgroud)

php get-headers

6
推荐指数
1
解决办法
5481
查看次数

标签 统计

get-headers ×1

php ×1