file_get_contents变量和字符串之间的区别是什么?

时间:2015-06-03 05:10:24

标签: php simple-html-dom

我有源代码:

一个。

$this->eArticle["product_link"] = 'http://afamily.vn/doi-song/lop-hoc-toa-tau-day-nham-mat-ve-obama-khien-tre-thich-me-20150530074455878.chn';
print file_get_contents($this->eArticle["product_link"]);

print file_get_contents('http://afamily.vn/doi-song/lop-hoc-toa-tau-day-nham-mat-ve-obama-khien-tre-thich-me-20150530074455878.chn');

在A中,结果返回NULL(screen haven't text

在B中,结果显示网站http://afamily.vn/doi-song/lop-hoc-toa-tau-day-nham-mat-ve-obama-khien-tre-thich-me-20150530074455878.chn

为什么?如何解决?谢谢!

1 个答案:

答案 0 :(得分:1)

我很确定你做了什么,但是

您可以尝试将其存储在变量中,功能为file_get_contents()而不是file_get_content()注意 " s" 你错过了

$this->eArticle["product_link"] = 'http://afamily.vn/doi-song/lop-hoc-toa-tau-day-nham-mat-ve-obama-khien-tre-thich-me-20150530074455878.chn';

$website_link = trim($this->eArticle["product_link"]);

echo file_get_contents($website_link);

查看Docs