在值输入中传递特殊字符复选框

  • 本文关键字:特殊字符 复选框 php
  • 更新时间 :
  • 英文 :


我需要在复选框字段的值内传递特殊字符。

特殊字符是:

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&ugrave; 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&ugrave;但不会Più

将这些 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);

最新更新