HTTP URL สามารถใช้ทำงานเหมือนไฟล์ในเครื่องได้ โดยใช้ PHP wrappers เนื้อหาจาก URL สามารถดึงผ่าน file_get_contents() และสามารถสะท้อนกลับได้ หรืออ่านโดยใช้ฟังก์ชัน 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.