我需要在复选框字段的值内传递特殊字符。
特殊字符为:
Più
m<sup>2</sup>
相当于单词
Più
m raised to 2
我这样做了,但是我不知道它是否正确:
<input type="radio" class="custom-control-input pradio" name="p8" id="p8_1"
value="<?php echo htmlspecialchars($stringadomanda8, ENT_QUOTES, 'UTF-8') ?>
di 60m<?php echo htmlspecialchars($iniziometroquadro)?>2<?php echo
htmlspecialchars($finemetroquadro, ENT_QUOTES, 'UTF-8')?>">
期望值如此的文件
$p8 = [
'Più di 60m<sup>2</sup>' => 1.00,
'Da 51 a 60m<sup>2</sup>' => 0.95,
'Da 41 a 50m<sup>2</sup>' => 0.90,
'Fino a 40m<sup>2</sup>' => 0.85,
'Piscina prefabbricata fino a 40m<sup>2</sup>' => 0.77,
];
我想确保带有特殊字符的值正确使用。
如果我尝试打印echo htmlspecialchars($stringadomanda8, ENT_QUOTES, 'UTF-8')
,则会得到Più
,但不会得到Più
。
答案 0 :(得分:0)
将这些HTML元素作为另一个HTML元素的值并不是很好,但这是您要的:
// encode string with htmlentities() when you load the form
$txt = 'Più m<sup>2</sup>';
$encoded = htmlentities($txt);
// decode it with html_entity_decode() when you have received the value
echo html_entity_decode($encoded);