Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当URL作为变量时,php文件\u获取\u内容错误_Php_Url_Variables_File Get Contents - Fatal编程技术网

当URL作为变量时,php文件\u获取\u内容错误

当URL作为变量时,php文件\u获取\u内容错误,php,url,variables,file-get-contents,Php,Url,Variables,File Get Contents,我正在努力解决文件获取内容()的奇怪问题 首先,代码从RSS地址加载XML。然后file\u get\u contents()使用XML中的页面地址获取HTML $url = 'http://www.moviejoy.com/rss/index.asp'; $rss = new DOMDocument(); $rss->load($url); foreach ($rss->getElementsByTagName('item') as $node) { $link = $n

我正在努力解决
文件获取内容()的奇怪问题

首先,代码从RSS地址加载XML。然后
file\u get\u contents()
使用XML中的页面地址获取HTML

$url = 'http://www.moviejoy.com/rss/index.asp';
$rss = new DOMDocument();
$rss->load($url);

foreach ($rss->getElementsByTagName('item') as $node) {
    $link = $node->getElementsByTagName('link')->item(0)->nodeValue;
    $html = file_get_contents($link);
    print_r($html);
}
这段代码给了我一个错误,上面写着:

警告:file_get_contents()[function.file get contents]:无法打开流:第135行的/[…]/index.php中没有这样的文件或目录

但是
当我直接放置URL而不是$link时,它就工作了。像这样:
$html=文件获取内容(http://www.moviejoy.com/qnam/view.asp?db=qna&num=2358);

我不知道该怎么解决这个问题。
请帮帮我

您可以在rss源中看到链接在此标记中:

<link>
http://www.moviejoy.com/qnam/view.asp?db=qna&amp;num=2387               
</link>
紧接着

$link = $node->getElementsByTagName('link')->item(0)->nodeValue;

基本调试:
var\u dump($link)
$link = $node->getElementsByTagName('link')->item(0)->nodeValue;