簡體   English   中英

在值輸入復選框中傳遞特殊字符

[英]Pass special characters in value input checkbox

我需要在復選框字段的值中傳遞特殊字符。

特殊字符是:

Più 
m<sup>2</sup>

相當於 word

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM