为了账号安全,请及时绑定邮箱和手机立即绑定

error on line 2 at column 1: Extra content at the end of the document

error on line 2 at column 1: Extra content at the end of the document

PHP
小沈程 2016-09-26 11:49:11
<?php/*** 按xml方式输出通信方式* @param integer $code状态码* @param string $message提示信息* @param array $data数据* return string*/class response{ public static function xmlEncode($code,$message,$data = array()){ if(!is_numeric($code)){ return ''; } $result = array('code' => $code,'message' => $message,'data' => $data); header('Content-Type:text/xml'); $xml = "<?xml version='1.0' encoding='UTF-8'?>"; $xml .="<root>"; $xml .= self::xmlToEncode($result); $xml .="</root>"; echo $xml; } public static function xmlToEncode($data){ $xml = ""; foreach($data as $key => $value){ $xml .= "<{$key}>"; $xml .= $value; $xml .= "</{$key}>"; } return $xml; }} $data = array( 'id' => 1, 'name' => 'fengxupeng', ); Response::xmlEncode(200,'success',$data);?>哪里出错啦 ??
查看完整描述

1 回答

?
rubyc

TA贡献47条经验 获得超7个赞

没有加根标签呀!XML文件只能有一个根标签!

查看完整回答
反对 回复 2016-09-26
  • 小沈程
    小沈程
    可是我看到视频上这么运行就可以呀!!麻烦告诉我一下,怎么改! 十分感谢啦
  • 1 回答
  • 0 关注
  • 2080 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信