PHP file_get_contents在本地服务器中不起作用 [英] Php file_get_contents not working in Local server

查看:91
本文介绍了PHP file_get_contents在本地服务器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MAC osX中启用了php,并且正常的php代码可以正常工作,但今天却遇到一个奇怪的错误

I enabled php in my MAC osX and normal php codes works fine , but I got one strange error today

<?php 
$hi = file_get_contents("https://ojooo.com");
echo $hi;
?>

对于上面的代码,我在本地服务器上遇到以下错误.但是上面的代码在我的主机上工作正常.

For the above code i get below error on my local server.But above code is working fine on my Hosting.

Warning: file_get_contents() [function.file-get-contents]: SSL operation failed with code 1. OpenSSL Error messages: error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112) in /Library/WebServer/Documents/hi/index.php on line 2

Warning: file_get_contents() [function.file-get-contents]: Failed to enable crypto in /Library/WebServer/Documents/hi/index.php on line 2

Warning: file_get_contents(https://ojooo.com) [function.file-get-contents]: failed to open stream: operation failed in /Library/WebServer/Documents/hi/index.php on line 2

正常的 file_get_content(https://yahoo.com); 正常工作.请有人帮我

the normal file_get_content(https://yahoo.com); is working fine.Please some one help me

推荐答案

问题是您试图将此站点重定向到SSL(https).然后,您需要 php_openssl.dll 模块.否则它不起作用.

The problem is this site you try to call redirects to SSL(https). And then you need the php_openssl.dll module. Otherwise its not working.

编辑活动的 php.ini 查找行:

; extension = php_openssl.dll

并取消注释.

您可以创建一个 phpinfo()并查看输出的顶部.在那里,您可以看到加载了哪个 php.ini 文件.

you can make an phpinfo() and look at the top of the output. There you can see which php.inifile is loaded.

这篇关于PHP file_get_contents在本地服务器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆