ຫົວຫຼັກ PHP simplexml_load_file()

ການອະທິບາຍ ແລະ ການນໍາໃຊ້

ຫົວຫຼັກ simplexml_load_file() ສາຍ XML ບັນທຶກເຂົ້າໃນອາຍອມຂອງບັນທຶກ XML。

ຖ້າບໍ່ປະສົບຜົນຜ່ານ ຈະກັບຄືນ false。

ປະຫວັດສາດ

simplexml_load_file(file,class,options,ns,is_prefix)
ປະກອບປະກອບ ການອະທິບາຍ
file ຕ້ອງການ. ຈະກໍານົດເອກະສານ XML ທີ່ຈະໃຊ້.
class ທາງຫາຍ. ຈະກໍານົດປະເພດຂອງອົງການໃໝ່.
options ທາງຫາຍ. ຈະກໍານົດມູນທີ່ຫຼັງສັນຍານ Libxml.
ns ທາງຫາຍ
is_prefix ທາງຫາຍ

ຜົນຂອງການອອກສຽງ

ຮັບອອກໂອວາລະບັນ SimpleXMLElement ທີ່ມີມູນຂອງເອກະສານ XML. ຖ້າບໍ່ປະສົບຜົນ ຈະຮັບອອກ false.

ຕົວຢ່າງ

XML ຕົວຊີວິດ:

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body>
</note>

PHP 代码:

<?php
if (file_exists('test.xml'))
  {
  $xml = simplexml_load_file('test.xml');
  var_dump($xml);
  }
else
  {
  exit('Error.');
  }
?>

ຄາດິດການອອກສຽງ:

object(SimpleXMLElement)#1 (4)
{
["to"]=> string(4) "George"
["from"]=> string(4) "John"
["heading"]=> string(8) "Reminder"
["body"]=> string(29) "Don't forget the meeting!"
}