调用url检索列表

时间:2016-05-16 15:00:16

标签: php web-services serialization php-5.4

我有一个问题。我需要从此网址/wd/biling.php?get&id=1获取数据。我现在知道此网址会返回liste serialize。我尝试使用$data= file_get_contents('/wd/biling.php?get&id=1');进行检索,但我收到错误:Failed to open stream。你能帮帮我吗?

1 个答案:

答案 0 :(得分:1)

网址只能作为绝对传递(使用Protocol + Host + Path)。 试试:

 file_get_contents('http[s]://domain/path');

此外,如果您以这种方式加载任何本地内容,您可能会做错事。我们使用 include require 来运行本地php文件。 你可以用这种方式。

 $id = 1;
 include('/wd/biling.php');

现在在 biling.php 中你就可以使用$ id了。