PHP怎么写XML
时间:2021-07-01 10:21:17
帮助过:29人阅读
PHP如何写XML
在PHP文件中有一个$_SESSION['phone'],想把它的值写入XML文件,该怎样实现?
------解决方案--------------------http://www.gxlcms.com/article/21450.htm
------解决方案--------------------XML与PHP相互转换封装函数:xmlparse.php
Demo:
PHP code
include(dirname(__FILE__)."/xmlparse.php");
$arr = array(1,"name","admin",100);
$contXML = dump_xml_config($arr, "xml", "utf-8");
//放入文件
file_put_contents_safe("/path/test.xml",$contXML,"w");
echo $contXML;
#源码
#
#
# <0>10>
# <1>name1>
# <2>admin2>
# <3>1003>
#
------解决方案--------------------