【发布时间】:2015-01-21 15:38:11
【问题描述】:
我正在尝试使用此代码从不属于我的网站获取一些数据。
<?
$text = file_get_contents("https://ninjacourses.com/explore/4/");
echo $text;
?>
但是,没有任何内容被回显,字符串长度为 0。
这个方法我以前做过,没问题,但是用这个网站,根本不行。
谢谢!
【问题讨论】:
-
不要认为它与 HTTPS 一起工作得很好......手册说它在失败时返回 false - 会支付给 var_dump() 输出以确保。类似情况也请参见this article here。
-
您是否在
php.ini文件中启用了allow_url_fopen? -
如果您启用 error_reporting 您将看到以下错误:
SSL operation failed with code 1. OpenSSL Error messages: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure -
我已启用
allow_url_fopen。默认开启。 -
你不能......你必须使用curl
标签: php