正在生成基于XML配置值的单选按钮。有时他们在文中有撇号。在PHP中操作这些数据时,
<input type='radio' name='remove[]' value='Government wants to limit employers' communications about unionization'>
但是当在表单POST之后将其转储出去时,我会得到这个值:
array(1) {
[0]=>
string(35) "Government wants to limit employers"
}
如何保留完整字符串?
发布于 2018-06-14 19:14:56
<input type="radio" ... value="<?php echo htmlspecialchars($array[0], ENT_QUOTES) ?>" ... />
明确地打算允许将任意文本安全地插入到html中而不会破坏html。请注意'ent_quotes'选项。默认情况下,htmlspecialchars只会处理<>"
,但由于正在使用'
,需要选择告诉htmlspecialchars来处理这些。
发布于 2018-06-14 20:32:40
可以在字符串中使用value='Government wants to limit employers' communications about unionization'
转义引号:转义它将导致此问题停止。
https://stackoverflow.com/questions/-100005400
复制相似问题