在 PHP 包装器的帮助下,HTTP URL 的行为可以像本地文件一样。可以通过 file_get_contents() 获取 URL 的内容,并且可以对其进行回显。或使用 readfile 函数读取。
下面是执行相同操作的示例代码 -
'$file = file_get_contents('http://example.com/');
echo $file;
下面演示了一种替代方案 -
'readfile('http://example.com/');
header('Content-type: text/xml'); //The correct MIME type has to be set before displaying the output.
也可以使用asXML方法。以下是示例代码 -
'echo $xml->asXML();
or
$xml->asXML('filename.xml'); //providing a name for the xml file.