【发布时间】:2015-10-15 06:13:21
【问题描述】:
我正在尝试将隐藏的输入字段值设置为从数组获得的 xml 字符串。
但是hidden 字段值显示在html 中,而当我将普通文本作为值放在隐藏字段中时,它可以正常工作。
//a large sized associative array convert to xml and set as hidden field
$item_array=array();
$xml=new SimpleXMLElement('<OriginDestinationOption/>');
array_walk_recursive($item_array,array($xml,'addChild'));
echo '<input type="hidden" name="return-xml" value="'.$xml->asXML();.'" />'; ?>
但它以 html 形式显示值。我的代码有什么问题?
注意:我正在使用 codeigniter 框架
【问题讨论】:
-
您的值也可能包含双引号
-
不应该
echo '<input type="hidden" name="return-xml" value="'.$xml->asXML();.'" />'; ?>是echo '<input type="hidden" name="return-xml" value="'.$xml->asXML().'" />' ?>吗?删除asXML()处的分号。
标签: php html codeigniter