相同的主机和file_get_contents

时间:2013-06-13 15:13:58

标签: php curl file-get-contents hosts

我遇到了file_get_contents函数的问题。 一周前,每件事都很完美。今天,当我通过file_get_contents调用同一个HOST / Server上的文件时,它会失败。结果是,我得到了google.de的首字母缩写。

然后我尝试通过curl在控制台中调用相同的full-url(http://www.mydomains.com/script/test.php)。结果是一个空字符串。但是其他服务器/主机上的文件可以毫无问题地调用。使用file_get_contents和console-> curl。

任何想法,如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

您的防火墙规则可能会阻止您调用自己的URL,但您可以使用带有file_get_contents的“真实”路径:

http://php.net/manual/en/function.file-get-contents.php

$ file = file_get_contents('/ path / to / file / people.txt',true);