編輯
如何在XML 「頭」 加編碼XML響應
現在的 「頭」 是這樣的:
<?xml version="1.0"?>
你怎麼能使用SimpleXML時在PHP中添加一個編碼在「標題」?
我的XML類:
class XML {
private $root = '<response />';
function __construct($root=null){
$this->root = new SimpleXMLElement($root ? $root:$this->root);
}
function encode($arr, $node=null){
$node = $node == null ? $this->root:$node;
foreach($arr as $key => $value){
if(is_array($value)){
$this->encode($value, $node->addChild($key));
}
else{
$node->addChild($key, $value);
}
}
}
function output(){
return $this->root->asXML();
}
}
什麼是錯誤您收到? – jerluc
在我的問題看看 – clarkk