主页
PHP
PHP addAttribute() 函数
demo_func_simplexml_addattribute
运行 ❯
×
更改方向
保存代码
更改主题
<?php $note=<<
Tove
Jani
Reminder
Do not forget me this weekend! XML; $xml=new SimpleXMLElement($note); // Add attribute to root element $xml->addAttribute("type","private"); // Add attribute to body element $xml->body->addAttribute("date","2014-01-01"); echo $xml->asXML(); ?>
Select View Source to see the added "type" and "date" attributes.