Php file_get_contents()在不同的计算机上的工作方式不同

Php file_get_contents()在不同的计算机上的工作方式不同,php,ssl,file-get-contents,Php,Ssl,File Get Contents,我编写了一段php代码,使用file\u get\u contents()从站点下载一个.js文件,并尝试从两台不同的机器上运行代码,它们会产生不同的结果。代码是: $link = "https://www.scotchwhiskyauctions.com/scripting/store-scripting_frontend.js"; $options = array( 'http'=>array( 'method'=>"GET", 'header'=>

我编写了一段php代码,使用
file\u get\u contents()
从站点下载一个.js文件,并尝试从两台不同的机器上运行代码,它们会产生不同的结果。代码是:

$link = "https://www.scotchwhiskyauctions.com/scripting/store-scripting_frontend.js";

$options = array(
  'http'=>array(
     'method'=>"GET",
     'header'=>"Accept-language: en\r\n" .
          "User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10\r\n"  ),
  'ssl'=>array(
     'verify_peer'=>false,
     'verify_peer_name'=>false),
);
$context = stream_context_create($options);
$line = file_get_contents($link, false, $context);
var_dump($http_response_header);
echo $line;
exit;
当我在Debian 8.11机器上运行这段代码时,会产生以下错误:

PHP Warning:  file_get_contents(https://www.scotchwhiskyauctions.com/scripting/store-scripting_frontend.js): failed to open stream: Connection timed out in /var/www/test.php on line 4
PHP Notice:  Undefined variable: http_response_header in /var/www/test.php on line 4
NULL
但是,当我在不同的机器上运行完全相同的代码(Debian 4.16.12-1Cali1)时,它可以获得文件内容,变量
$http\u response\u header
包含所有响应头。两台机器都使用php7.2。在花了几天时间试图找出导致Debian 8.11机器无法读取文件的原因后,我在两台机器上都使用了
wget
,并再次注意到Debian 8.11(jessie)机器无法读取文件

我怀疑这与ssl证书有关,所以我运行了

sudo update-ca-certificates
sudo update-ca-certificates --fresh
但这毫无帮助


有谁能给我指个方向吗?

最后,我根据别人的评论解决了这个问题

我在文章中发现了以下内容

/proc/sys/net/ipv4/tcp\u时间戳

除其他外,时间戳用于防止 包装序列号。可以想象,1GB的链路 重新遇到前一个序列号的值不符, 因为它是上一代的。时间戳将允许它 认识这个“古老的包裹”


然而,我不知道为什么它会起作用。有人能解释一下吗?

你在哪里定义
$http\u response\u header
?@Dormilich
$http\u response\u header
是自动填充的-你不必定义它:
允许url\u fopen
在两台机器的
php.ini
文件中都设置为On,仅供参考。@albertma789你能访问url吗?(使用浏览器f.e.)@Xatenev是的,我可以。
echo 0 > /proc/sys/net/ipv4/tcp_timestamps