file_get_contents - 连接超时

Bru*_*uno 6 php

<?php
$a = file_get_contents('http://www.google.com');
echo $
Run Code Online (Sandbox Code Playgroud)

为什么浏览器会返回此错误?

Warning: file_get_contents(http://www.google.com) [function.file-get-contents]: failed to open stream: Connection timed out in /home/test.php on line 2
Run Code Online (Sandbox Code Playgroud)

Ham*_*ish 3

您的服务器很可能无法连接到外部资源,例如,由于防火墙限制。

  • ...或者谷歌已经宕机了,但这似乎不太可能:D (3认同)