PHP simplexml_load_file() သုံးစွဲသည်

အသုံးပြုခြင်း နှင့် အသုံးပြုခြင်း

simplexml_load_file() သုံးစွဲသည် ယူကျဖ် စာမျက်နှာကို အရာဝတ္တုထဲသို့ ဆောက်လုပ်သည်。

အောင်မမှုတ်တယ်ဖြစ်လာရင် false ပြန်လည်သတင်းပေးသည်。

ပြောင်းလဲ

simplexml_load_file(file,class,options,ns,is_prefix)
ပထမဆုံး ဖော်ပြ
file required. Specify the XML document to be used.
class optional. Specify the new object's class.
options optional. Specify additional Libxml parameters.
ns optional.
is_prefix optional.

return value

return အရာ SimpleXMLElement တစ်ခု သည် အရေးပါသော အချိန် အခြေခံ များ ပါဝင်သည်။ အကျိုးသက် မပြီးဆုံးခဲ့ကြောင်း ဖော်ပြသည်။

အကျိုးသက်

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.');
  }
?>

Output:

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