【发布时间】:2015-08-11 03:53:34
【问题描述】:
我有以下代码:
<?php
//first try
$url = 'http://www.omdbapi.com';
echo '<pre>';
print_r(file_get_contents($url));
echo '</pre>';
//second try
$url = 'http://www.omdbapi.com/?t=the dark night';
echo '<pre>';
print_r(file_get_contents($url));
echo '</pre>';
?>
第一次尝试效果很好。但是,第二次尝试给出以下错误消息,没有更多详细信息:
$file_get_contents(http://www.omdbapi.com/?t=the dark night): failed to open stream: HTTP request failed!
请注意,pc 有 windows 8.1 x64,我已经尝试过 wamp server 和 xampp。我确实确保两个 $php.ini 文件都启用了扩展 $extension=php_openssl.dll 和 $extension=php_curl.dll
【问题讨论】:
-
尝试用
%20替换你的url中的空格。
标签: php json codeigniter