PHP attributes() ပုံစံ

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

attributes() ပုံစံ သည် SimpleXML အရာဝတ္တု အခွင့်အရေး ကို ရယူ လေ့ ရှိသည်။

ဒီ ပုံစံ သည် အချိန်ခုနှစ် အရ ပုံစံ နှင့် အသုံးပြုခြင်း နှင့် ပတ်သတ် သည်။

ပုံစံ

class SimpleXMLElement
{
string attributes(ns,is_prefix)
}
ပါဝင်သည် ဖော်ပြ
ns ဆိုခဲ့သော အခွင့်အရေး ကို ရှာဖွေ ရန် သဘောတူ မျှော်လင့်
is_prefix အဆိုပါ ဖိုင် က ဆိုခဲ့သော အခြေခံ မဟုတ် သည်။ ပုံစံ အခြေခံ အတွက် false ဖြစ်သည်။

အကြိုးအပျက်

XML ဖိုင်:

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

PHP ပုံစံ:

<?php
$xml = simplexml_load_file("test.xml");
foreach($xml->body[0]->attributes() as $a => $b)
  {
  echo $a,'="',$b,'"';
  }
?>

ထုတ်လုပ်ခြင်း:

type="small" important="low"